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)
|
||||
.insert(spatialbundle)
|
||||
.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,
|
||||
mass_properties,
|
||||
damping,
|
||||
|
|
|
@ -37,8 +37,8 @@ impl Default for WheelConfig {
|
|||
limits: [-0.5, 0.1],
|
||||
stiffness: 50.0,
|
||||
damping: 8.0,
|
||||
radius: 0.35,
|
||||
thickness: 0.10,
|
||||
radius: 0.3,
|
||||
thickness: 0.06,
|
||||
friction: 1.2,
|
||||
restitution: 0.8,
|
||||
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::{
|
||||
Ccd, CoefficientCombineRule, Collider, ColliderMassProperties, CollisionGroups, Damping,
|
||||
ExternalForce, Friction, MultibodyJoint, PrismaticJointBuilder, Restitution,
|
||||
|
@ -27,9 +27,9 @@ pub fn spawn_tires(
|
|||
|
||||
let tire = Tire {
|
||||
radius: wheel_rad,
|
||||
ring_radius: tire_thickness,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let material = StandardMaterial {
|
||||
base_color: Color::Rgba {
|
||||
red: 0.01,
|
||||
|
@ -82,18 +82,8 @@ pub fn spawn_tires(
|
|||
for idx in indices.as_slice().chunks_exact(3) {
|
||||
idxs.push([idx[0] as u32, idx[1] as u32, idx[2] as u32]);
|
||||
}
|
||||
let wheel_collider = Collider::convex_decomposition(
|
||||
&mesh
|
||||
.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 wheel_collider = Collider::round_cylinder(tire_thickness, wheel_rad, tire_thickness);
|
||||
let mass_props = ColliderMassProperties::Density(conf.density);
|
||||
let damping = conf.damping;
|
||||
|
||||
|
@ -129,8 +119,11 @@ pub fn spawn_tires(
|
|||
fork_rb_entity
|
||||
};
|
||||
|
||||
let revolute_builder = RevoluteJointBuilder::new(Vec3::X);
|
||||
let axel_joint = MultibodyJoint::new(axel_parent_entity, revolute_builder);
|
||||
let axel_builder = RevoluteJointBuilder::new(Vec3::Y);
|
||||
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((
|
||||
wheel_collider,
|
||||
|
@ -144,7 +137,6 @@ pub fn spawn_tires(
|
|||
CyberWheel,
|
||||
ExternalForce::default(),
|
||||
Restitution::new(conf.restitution),
|
||||
SpatialBundle::default(),
|
||||
TransformInterpolation::default(),
|
||||
RigidBody::Dynamic,
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue