diff options
| author | Sébastien Crozet <sebcrozet@dimforge.com> | 2024-04-21 18:55:11 +0200 |
|---|---|---|
| committer | Sébastien Crozet <sebastien@crozet.re> | 2024-04-30 23:10:46 +0200 |
| commit | f58b4f7c195ab7acf0778ea65c46ebf37ac8188c (patch) | |
| tree | 16a5009b1decbf0395b93657b5c992b277bff8f9 /src/geometry | |
| parent | da79d6fb5b28dd12e17ef4c8985fb589a37c9f9c (diff) | |
| download | rapier-f58b4f7c195ab7acf0778ea65c46ebf37ac8188c.tar.gz rapier-f58b4f7c195ab7acf0778ea65c46ebf37ac8188c.tar.bz2 rapier-f58b4f7c195ab7acf0778ea65c46ebf37ac8188c.zip | |
feat: add warmstarting to contact constraints resolution
Diffstat (limited to 'src/geometry')
| -rw-r--r-- | src/geometry/contact_pair.rs | 18 | ||||
| -rw-r--r-- | src/geometry/narrow_phase.rs | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs index 44730a0..5db95c0 100644 --- a/src/geometry/contact_pair.rs +++ b/src/geometry/contact_pair.rs @@ -1,8 +1,9 @@ use crate::dynamics::{RigidBodyHandle, RigidBodySet}; use crate::geometry::{ColliderHandle, ColliderSet, Contact, ContactManifold}; -use crate::math::{Point, Real, Vector}; +use crate::math::{Point, Real, TangentImpulse, Vector, ANG_DIM}; use crate::pipeline::EventHandler; use crate::prelude::CollisionEventFlags; +use parry::math::AngVector; use parry::query::ContactManifoldsWorkspace; use super::CollisionEvent; @@ -33,12 +34,11 @@ pub struct ContactData { pub impulse: Real, /// The friction impulse along the vector orthonormal to the contact normal, applied to the first /// collider's rigid-body. - #[cfg(feature = "dim2")] - pub tangent_impulse: Real, - /// The friction impulses along the basis orthonormal to the contact normal, applied to the first - /// collider's rigid-body. - #[cfg(feature = "dim3")] - pub tangent_impulse: na::Vector2<Real>, + pub tangent_impulse: TangentImpulse<Real>, + /// The impulse retained for warmstarting the next simulation step. + pub warmstart_impulse: Real, + /// The friction impulse retained for warmstarting the next simulation step. + pub warmstart_tangent_impulse: TangentImpulse<Real>, } impl Default for ContactData { @@ -46,6 +46,8 @@ impl Default for ContactData { Self { impulse: 0.0, tangent_impulse: na::zero(), + warmstart_impulse: 0.0, + warmstart_tangent_impulse: na::zero(), } } } @@ -299,6 +301,8 @@ pub struct SolverContact { pub tangent_velocity: Vector<Real>, /// Whether or not this contact existed during the last timestep. pub is_new: bool, + pub warmstart_impulse: Real, + pub warmstart_tangent_impulse: TangentImpulse<Real>, } impl SolverContact { diff --git a/src/geometry/narrow_phase.rs b/src/geometry/narrow_phase.rs index f754808..a711117 100644 --- a/src/geometry/narrow_phase.rs +++ b/src/geometry/narrow_phase.rs @@ -987,6 +987,8 @@ impl NarrowPhase { restitution, tangent_velocity: Vector::zeros(), is_new: contact.data.impulse == 0.0, + warmstart_impulse: contact.data.warmstart_impulse, + warmstart_tangent_impulse: contact.data.warmstart_tangent_impulse, }; manifold.data.solver_contacts.push(solver_contact); |
