diff options
| author | Thierry Berger <contact@thierryberger.com> | 2024-09-13 10:48:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-13 10:48:56 +0200 |
| commit | c714ff81f2be61f433d0521bc56ba44ce0e71298 (patch) | |
| tree | b331203cee1c4291bcb74222c5b6ee792eb97536 /examples3d | |
| parent | 04058a111dcb99393e52158823c0f7d6a87407fb (diff) | |
| download | rapier-c714ff81f2be61f433d0521bc56ba44ce0e71298.tar.gz rapier-c714ff81f2be61f433d0521bc56ba44ce0e71298.tar.bz2 rapier-c714ff81f2be61f433d0521bc56ba44ce0e71298.zip | |
ImpulseJointSet::get_mut option to wake up connected bodies (#716)
Diffstat (limited to 'examples3d')
| -rw-r--r-- | examples3d/vehicle_joints3.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/examples3d/vehicle_joints3.rs b/examples3d/vehicle_joints3.rs index c284175..517bd9c 100644 --- a/examples3d/vehicle_joints3.rs +++ b/examples3d/vehicle_joints3.rs @@ -158,14 +158,17 @@ pub fn init_world(testbed: &mut Testbed) { _ => {} } } - + let mut should_wake_up = false; if thrust != 0.0 || steering != 0.0 { - physics.bodies.get_mut(body_handle).unwrap().wake_up(true); + should_wake_up = true; } // Apply steering to the axles. for steering_handle in &steering_joints { - let steering_joint = physics.impulse_joints.get_mut(*steering_handle).unwrap(); + let steering_joint = physics + .impulse_joints + .get_mut(*steering_handle, should_wake_up) + .unwrap(); steering_joint.data.set_motor_position( JointAxis::AngY, max_steering_angle * steering, @@ -187,7 +190,10 @@ pub fn init_world(testbed: &mut Testbed) { let ms = [1.0 / speed_diff, speed_diff]; for (motor_handle, &ms) in motor_joints.iter().copied().zip(ms.iter()) { - let motor_joint = physics.impulse_joints.get_mut(motor_handle).unwrap(); + let motor_joint = physics + .impulse_joints + .get_mut(motor_handle, should_wake_up) + .unwrap(); motor_joint.data.set_motor_velocity( JointAxis::AngX, -30.0 * thrust * ms * boost, |
