diff options
| author | Sébastien Crozet <developer@crozet.re> | 2023-03-26 15:17:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-26 15:17:53 +0200 |
| commit | 66fdc38d5480f3bdd305a09b073b08554f26b870 (patch) | |
| tree | 89093e785ce1063e8389d1863699376148b3485b /src | |
| parent | e4e37b4d9cabe883887bae8495920973a36301c6 (diff) | |
| parent | 8bd289bc73175be477b182ca4d92cb0944fbfe17 (diff) | |
| download | rapier-66fdc38d5480f3bdd305a09b073b08554f26b870.tar.gz rapier-66fdc38d5480f3bdd305a09b073b08554f26b870.tar.bz2 rapier-66fdc38d5480f3bdd305a09b073b08554f26b870.zip | |
Merge pull request #468 from aunyks/ray-cast-vehicle-lateral-wheel-grip
Add Ability to Control Side-to-Side Grip / Forward Grip of Raycast Vehicle Wheels
Diffstat (limited to 'src')
| -rw-r--r-- | src/control/ray_cast_vehicle_controller.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/control/ray_cast_vehicle_controller.rs b/src/control/ray_cast_vehicle_controller.rs index 42bb112..5daa435 100644 --- a/src/control/ray_cast_vehicle_controller.rs +++ b/src/control/ray_cast_vehicle_controller.rs @@ -37,7 +37,9 @@ pub struct WheelTuning { pub suspension_damping: Real, /// The maximum distance the suspension can travel before and after its resting length. pub max_suspension_travel: Real, - /// Parameter controlling how much traction the tire his. + /// The multiplier of friction between a tire and the collider it's on top of. + pub side_friction_stiffness: Real, + /// Parameter controlling how much traction the tire has. /// /// The larger the value, the more instantaneous braking will happen (with the risk of /// causing the vehicle to flip if it’s too strong). @@ -53,6 +55,7 @@ impl Default for WheelTuning { suspension_compression: 0.83, suspension_damping: 0.88, max_suspension_travel: 5.0, + side_friction_stiffness: 1.0, friction_slip: 10.5, max_suspension_force: 6000.0, } @@ -86,13 +89,15 @@ struct WheelDesc { /// /// Increase this value if the suspension appears to overshoot. pub damping_relaxation: Real, - /// Parameter controlling how much traction the tire his. + /// Parameter controlling how much traction the tire has. /// /// The larger the value, the more instantaneous braking will happen (with the risk of /// causing the vehicle to flip if it’s too strong). pub friction_slip: Real, /// The maximum force applied by the suspension. pub max_suspension_force: Real, + /// The multiplier of friction between a tire and the collider it's on top of. + pub side_friction_stiffness: Real, } #[derive(Copy, Clone, Debug, PartialEq)] @@ -128,11 +133,13 @@ pub struct Wheel { /// /// Increase this value if the suspension appears to overshoot. pub damping_relaxation: Real, - /// Parameter controlling how much traction the tire his. + /// Parameter controlling how much traction the tire has. /// /// The larger the value, the more instantaneous braking will happen (with the risk of /// causing the vehicle to flip if it’s too strong). - friction_slip: Real, + pub friction_slip: Real, + /// The multiplier of friction between a tire and the collider it's on top of. + pub side_friction_stiffness: Real, /// The wheel’s current rotation on its axle. pub rotation: Real, delta_rotation: Real, @@ -189,6 +196,7 @@ impl Wheel { skid_info: 0.0, side_impulse: 0.0, forward_impulse: 0.0, + side_friction_stiffness: info.side_friction_stiffness, } } @@ -260,6 +268,7 @@ impl DynamicRayCastVehicleController { friction_slip: tuning.friction_slip, max_suspension_travel: tuning.max_suspension_travel, max_suspension_force: tuning.max_suspension_force, + side_friction_stiffness: tuning.side_friction_stiffness, }; let wheel_id = self.wheels.len(); @@ -509,8 +518,6 @@ impl DynamicRayCastVehicleController { } } - const SIDE_FRICTION_STIFFNESS2: Real = 1.0; - fn update_friction(&mut self, bodies: &mut RigidBodySet, colliders: &ColliderSet, dt: Real) { let num_wheels = self.wheels.len(); @@ -574,7 +581,7 @@ impl DynamicRayCastVehicleController { ); } - wheel.side_impulse *= Self::SIDE_FRICTION_STIFFNESS2; + wheel.side_impulse *= wheel.side_friction_stiffness; } } } |
