diff options
| author | Crozet Sébastien <developer@crozet.re> | 2020-09-21 10:43:20 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2020-09-28 15:27:25 +0200 |
| commit | 7b8e322446ffa36e3f47078e23eb61ef423175dc (patch) | |
| tree | 4064de8761d7f07d243c44e0bfc8de098939f492 /src/dynamics/rigid_body.rs | |
| parent | e16b7722be23f7b6627bd54e174d7782d33c53fe (diff) | |
| download | rapier-7b8e322446ffa36e3f47078e23eb61ef423175dc.tar.gz rapier-7b8e322446ffa36e3f47078e23eb61ef423175dc.tar.bz2 rapier-7b8e322446ffa36e3f47078e23eb61ef423175dc.zip | |
Make kinematic bodies properly wake up dynamic bodies.
Diffstat (limited to 'src/dynamics/rigid_body.rs')
| -rw-r--r-- | src/dynamics/rigid_body.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index d32ea46..af1fb4a 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -181,10 +181,13 @@ impl RigidBody { } /// Wakes up this rigid body if it is sleeping. - pub fn wake_up(&mut self) { + /// + /// If `strong` is `true` then it is assured that the rigid-body will + /// remain awake during multiple subsequent timesteps. + pub fn wake_up(&mut self, strong: bool) { self.activation.sleeping = false; - if self.activation.energy == 0.0 && self.is_dynamic() { + if (strong || self.activation.energy == 0.0) && self.is_dynamic() { self.activation.energy = self.activation.threshold.abs() * 2.0; } } @@ -198,9 +201,18 @@ impl RigidBody { /// Is this rigid body sleeping? pub fn is_sleeping(&self) -> bool { + // TODO: should we: + // - return false for static bodies. + // - return true for non-sleeping dynamic bodies. + // - return true only for kinematic bodies with non-zero velocity? self.activation.sleeping } + /// Is the velocity of this body not zero? + pub fn is_moving(&self) -> bool { + !self.linvel.is_zero() || !self.angvel.is_zero() + } + fn integrate_velocity(&self, dt: f32) -> Isometry<f32> { let com = &self.position * self.mass_properties.local_com; let shift = Translation::from(com.coords); |
