no colliders for wheels
This commit is contained in:
parent
8a440d6e81
commit
e358830c5f
2 changed files with 7 additions and 29 deletions
|
@ -2,13 +2,12 @@ use bevy::prelude::*;
|
||||||
use bevy_rapier3d::{
|
use bevy_rapier3d::{
|
||||||
dynamics::{FixedJointBuilder, Velocity},
|
dynamics::{FixedJointBuilder, Velocity},
|
||||||
prelude::{
|
prelude::{
|
||||||
Ccd, CoefficientCombineRule, Collider, ColliderMassProperties, CollisionGroups, Damping,
|
ColliderMassProperties, ExternalForce, MultibodyJoint, PrismaticJointBuilder, RigidBody,
|
||||||
ExternalForce, Friction, MultibodyJoint, PrismaticJointBuilder, Restitution,
|
Sleeping, TransformInterpolation,
|
||||||
RevoluteJointBuilder, RigidBody, Sleeping, TransformInterpolation,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{CyberSteering, CyberWheel, Meshterial, WheelConfig, BIKE_WHEEL_COLLISION_GROUP};
|
use super::{CyberSteering, CyberWheel, Meshterial, WheelConfig};
|
||||||
use crate::action::PreviousVelocity;
|
use crate::action::PreviousVelocity;
|
||||||
|
|
||||||
pub(crate) fn spawn_wheels(
|
pub(crate) fn spawn_wheels(
|
||||||
|
@ -17,21 +16,13 @@ pub(crate) fn spawn_wheels(
|
||||||
conf: &WheelConfig,
|
conf: &WheelConfig,
|
||||||
meshterials: &mut Meshterial,
|
meshterials: &mut Meshterial,
|
||||||
) {
|
) {
|
||||||
let (membership, filter) = BIKE_WHEEL_COLLISION_GROUP;
|
|
||||||
let wheels_collision_group = CollisionGroups::new(membership, filter);
|
|
||||||
let wheel_y = conf.y;
|
let wheel_y = conf.y;
|
||||||
let stiffness = conf.stiffness;
|
let stiffness = conf.stiffness;
|
||||||
let not_sleeping = Sleeping::disabled();
|
let not_sleeping = Sleeping::disabled();
|
||||||
let ccd = Ccd { enabled: true };
|
|
||||||
let limits = conf.limits;
|
let limits = conf.limits;
|
||||||
let (meshes, materials) = meshterials;
|
let (meshes, materials) = meshterials;
|
||||||
let rake_vec: Vec3 = Vec3::new(0.0, 1.0, 0.57).normalize(); // about 30 degrees of rake
|
let rake_vec: Vec3 = Vec3::new(0.0, 1.0, 0.57).normalize(); // about 30 degrees of rake
|
||||||
|
|
||||||
let friction = Friction {
|
|
||||||
coefficient: conf.friction,
|
|
||||||
combine_rule: CoefficientCombineRule::Min,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut wheel_poses = Vec::with_capacity(2);
|
let mut wheel_poses = Vec::with_capacity(2);
|
||||||
|
|
||||||
// front
|
// front
|
||||||
|
@ -51,7 +42,7 @@ pub(crate) fn spawn_wheels(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (offset, steering) in wheel_poses {
|
for (offset, steering) in wheel_poses {
|
||||||
let (mesh, collider) = gen_tires(conf);
|
let mesh = gen_tires(conf);
|
||||||
|
|
||||||
let material = StandardMaterial {
|
let material = StandardMaterial {
|
||||||
base_color: Color::YELLOW,
|
base_color: Color::YELLOW,
|
||||||
|
@ -93,7 +84,6 @@ pub(crate) fn spawn_wheels(
|
||||||
.spawn(RigidBody::Dynamic)
|
.spawn(RigidBody::Dynamic)
|
||||||
.insert(neck_joint)
|
.insert(neck_joint)
|
||||||
.insert(steering)
|
.insert(steering)
|
||||||
.insert(not_sleeping)
|
|
||||||
.id();
|
.id();
|
||||||
neck
|
neck
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,15 +94,11 @@ pub(crate) fn spawn_wheels(
|
||||||
let axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
|
let axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
|
||||||
|
|
||||||
commands.spawn(pbr_bundle).insert((
|
commands.spawn(pbr_bundle).insert((
|
||||||
collider,
|
|
||||||
mass_props,
|
mass_props,
|
||||||
//wheel_damping,
|
//wheel_damping,
|
||||||
ccd,
|
|
||||||
not_sleeping,
|
|
||||||
axel_joint,
|
axel_joint,
|
||||||
wheels_collision_group,
|
|
||||||
friction,
|
|
||||||
CyberWheel,
|
CyberWheel,
|
||||||
|
not_sleeping,
|
||||||
Velocity::default(),
|
Velocity::default(),
|
||||||
PreviousVelocity::default(),
|
PreviousVelocity::default(),
|
||||||
ExternalForce::default(),
|
ExternalForce::default(),
|
||||||
|
@ -124,11 +110,8 @@ pub(crate) fn spawn_wheels(
|
||||||
}
|
}
|
||||||
|
|
||||||
// do mesh shit
|
// do mesh shit
|
||||||
fn gen_tires(conf: &WheelConfig) -> (Mesh, Collider) {
|
fn gen_tires(conf: &WheelConfig) -> Mesh {
|
||||||
let wheel_rad = conf.radius;
|
let wheel_rad = conf.radius;
|
||||||
let tire = Sphere::new(wheel_rad);
|
let tire = Sphere::new(wheel_rad);
|
||||||
let mesh = Mesh::from(tire);
|
Mesh::from(tire)
|
||||||
let wheel_collider = Collider::ball(wheel_rad);
|
|
||||||
|
|
||||||
(mesh, wheel_collider)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ use bevy::{
|
||||||
TextBundle, TextSection, TextStyle, Transform, With,
|
TextBundle, TextSection, TextStyle, Transform, With,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
//#[cfg(feature = "inspector")]
|
|
||||||
//use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
|
||||||
use bevy_rapier3d::prelude::Velocity;
|
use bevy_rapier3d::prelude::Velocity;
|
||||||
|
|
||||||
use crate::bike::CyberBikeBody;
|
use crate::bike::CyberBikeBody;
|
||||||
|
@ -53,9 +51,6 @@ pub struct CyberUIPlugin;
|
||||||
|
|
||||||
impl Plugin for CyberUIPlugin {
|
impl Plugin for CyberUIPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
#[cfg(feature = "inspector")]
|
|
||||||
//app.add_plugins(WorldInspectorPlugin::new());
|
|
||||||
|
|
||||||
//
|
//
|
||||||
app.add_systems(Startup, setup_ui)
|
app.add_systems(Startup, setup_ui)
|
||||||
.add_systems(Update, update_ui);
|
.add_systems(Update, update_ui);
|
||||||
|
|
Loading…
Reference in a new issue