works?
This commit is contained in:
parent
122bf51879
commit
87d9d737d6
3 changed files with 12 additions and 20 deletions
|
@ -59,7 +59,7 @@ pub(super) fn spawn_cyberbike(
|
||||||
.spawn(RigidBody::Dynamic)
|
.spawn(RigidBody::Dynamic)
|
||||||
.insert(spatialbundle)
|
.insert(spatialbundle)
|
||||||
.insert((
|
.insert((
|
||||||
Collider::capsule(Vec3::new(0.0, 0.0, -0.65), Vec3::new(0.0, 0.0, 0.8), 0.50),
|
Collider::capsule(Vec3::new(0.0, 0.0, -0.65), Vec3::new(0.0, 0.0, 0.8), 0.40),
|
||||||
bike_collision_group,
|
bike_collision_group,
|
||||||
mass_properties,
|
mass_properties,
|
||||||
damping,
|
damping,
|
||||||
|
|
|
@ -37,8 +37,8 @@ impl Default for WheelConfig {
|
||||||
limits: [-0.5, 0.1],
|
limits: [-0.5, 0.1],
|
||||||
stiffness: 50.0,
|
stiffness: 50.0,
|
||||||
damping: 8.0,
|
damping: 8.0,
|
||||||
radius: 0.35,
|
radius: 0.3,
|
||||||
thickness: 0.10,
|
thickness: 0.06,
|
||||||
friction: 1.2,
|
friction: 1.2,
|
||||||
restitution: 0.8,
|
restitution: 0.8,
|
||||||
density: 0.6,
|
density: 0.6,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use bevy::prelude::{shape::Torus as Tire, *};
|
use bevy::prelude::{shape::UVSphere as Tire, *};
|
||||||
use bevy_rapier3d::prelude::{
|
use bevy_rapier3d::prelude::{
|
||||||
Ccd, CoefficientCombineRule, Collider, ColliderMassProperties, CollisionGroups, Damping,
|
Ccd, CoefficientCombineRule, Collider, ColliderMassProperties, CollisionGroups, Damping,
|
||||||
ExternalForce, Friction, MultibodyJoint, PrismaticJointBuilder, Restitution,
|
ExternalForce, Friction, MultibodyJoint, PrismaticJointBuilder, Restitution,
|
||||||
|
@ -27,9 +27,9 @@ pub fn spawn_tires(
|
||||||
|
|
||||||
let tire = Tire {
|
let tire = Tire {
|
||||||
radius: wheel_rad,
|
radius: wheel_rad,
|
||||||
ring_radius: tire_thickness,
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let material = StandardMaterial {
|
let material = StandardMaterial {
|
||||||
base_color: Color::Rgba {
|
base_color: Color::Rgba {
|
||||||
red: 0.01,
|
red: 0.01,
|
||||||
|
@ -82,18 +82,8 @@ pub fn spawn_tires(
|
||||||
for idx in indices.as_slice().chunks_exact(3) {
|
for idx in indices.as_slice().chunks_exact(3) {
|
||||||
idxs.push([idx[0] as u32, idx[1] as u32, idx[2] as u32]);
|
idxs.push([idx[0] as u32, idx[1] as u32, idx[2] as u32]);
|
||||||
}
|
}
|
||||||
let wheel_collider = Collider::convex_decomposition(
|
|
||||||
&mesh
|
let wheel_collider = Collider::round_cylinder(tire_thickness, wheel_rad, tire_thickness);
|
||||||
.attribute(Mesh::ATTRIBUTE_POSITION)
|
|
||||||
.unwrap()
|
|
||||||
.as_float3()
|
|
||||||
.unwrap()
|
|
||||||
.iter()
|
|
||||||
.map(|v| Vec3::from_array(*v))
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
&idxs,
|
|
||||||
);
|
|
||||||
//let wheel_collider = Collider::from_bevy_mesh(&mesh, computed_shape);
|
|
||||||
let mass_props = ColliderMassProperties::Density(conf.density);
|
let mass_props = ColliderMassProperties::Density(conf.density);
|
||||||
let damping = conf.damping;
|
let damping = conf.damping;
|
||||||
|
|
||||||
|
@ -129,8 +119,11 @@ pub fn spawn_tires(
|
||||||
fork_rb_entity
|
fork_rb_entity
|
||||||
};
|
};
|
||||||
|
|
||||||
let revolute_builder = RevoluteJointBuilder::new(Vec3::X);
|
let axel_builder = RevoluteJointBuilder::new(Vec3::Y);
|
||||||
let axel_joint = MultibodyJoint::new(axel_parent_entity, revolute_builder);
|
let mut axel_joint = MultibodyJoint::new(axel_parent_entity, axel_builder);
|
||||||
|
// re-orient the joint so that the wheel is correctly oriented
|
||||||
|
let real_axel = *axel_joint.data.set_local_axis1(Vec3::X);
|
||||||
|
axel_joint.data = real_axel;
|
||||||
|
|
||||||
commands.spawn(pbr_bundle.clone()).insert((
|
commands.spawn(pbr_bundle.clone()).insert((
|
||||||
wheel_collider,
|
wheel_collider,
|
||||||
|
@ -144,7 +137,6 @@ pub fn spawn_tires(
|
||||||
CyberWheel,
|
CyberWheel,
|
||||||
ExternalForce::default(),
|
ExternalForce::default(),
|
||||||
Restitution::new(conf.restitution),
|
Restitution::new(conf.restitution),
|
||||||
SpatialBundle::default(),
|
|
||||||
TransformInterpolation::default(),
|
TransformInterpolation::default(),
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
));
|
));
|
||||||
|
|
Loading…
Reference in a new issue