diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-03-28 11:26:53 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-03-28 11:27:07 +0200 |
| commit | 7306821c460ca3f77e697c89a79393e61c126624 (patch) | |
| tree | c8aa2a4d7d2c381706ee7edb60245bfd7bac7a07 /src/dynamics/rigid_body.rs | |
| parent | 710dd8d71ed53d2f52f15cdd19ee2f1248b62a96 (diff) | |
| download | rapier-7306821c460ca3f77e697c89a79393e61c126624.tar.gz rapier-7306821c460ca3f77e697c89a79393e61c126624.tar.bz2 rapier-7306821c460ca3f77e697c89a79393e61c126624.zip | |
Attenuate the warmstart impulse for CCD contacts.
CCD contacts result in very strong, instantaneous, impulses. So it is preferable to attenuate their contribution to subsequent timesteps to avoid overshooting.
Diffstat (limited to 'src/dynamics/rigid_body.rs')
| -rw-r--r-- | src/dynamics/rigid_body.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 9ac4763..e557df0 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -204,8 +204,12 @@ impl RigidBody { self.flags.contains(RigidBodyFlags::CCD_ENABLED) } + pub fn is_moving_fast(&self, dt: Real) -> bool { + self.is_dynamic() && self.linvel.norm() * dt > self.ccd_thickness + } + pub(crate) fn should_resolve_ccd(&self, dt: Real) -> bool { - self.is_ccd_enabled() && self.is_dynamic() && self.linvel.norm() * dt > self.ccd_thickness + self.is_ccd_enabled() && self.is_moving_fast(dt) } /// Sets the rigid-body's mass properties. @@ -371,10 +375,6 @@ impl RigidBody { shift * Isometry::new(self.linvel * dt, self.angvel * dt) * shift.inverse() } - pub(crate) fn position_at_time(&self, dt: Real) -> Isometry<Real> { - self.integrate_velocity(dt) * self.position - } - pub(crate) fn integrate_next_position(&mut self, dt: Real, apply_damping: bool) { // TODO: do we want to apply damping before or after the velocity integration? if apply_damping { @@ -504,10 +504,6 @@ impl RigidBody { self.linvel = dpos.translation.vector * inv_dt; } - pub(crate) fn update_next_position(&mut self, dt: Real) { - self.next_position = self.integrate_velocity(dt) * self.position; - } - pub(crate) fn update_world_mass_properties(&mut self) { self.world_com = self.mass_properties.world_com(&self.position); self.effective_inv_mass = self.mass_properties.inv_mass; |
