aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/contact_pair.rs
diff options
context:
space:
mode:
authorThierry Berger <contact@thierryberger.com>2024-06-03 15:20:24 +0200
committerThierry Berger <contact@thierryberger.com>2024-06-03 15:20:24 +0200
commite1ed90603e618e28f48916690d761e0d8213e2ad (patch)
tree8399da9825ca9ee8edd601b1265e818fa303b541 /src/geometry/contact_pair.rs
parentfe336b9b98d5825544ad3a153a84cb59dc9171c6 (diff)
parent856675032e76b6eb4bc9e0be4dc87abdbcfe0421 (diff)
downloadrapier-e1ed90603e618e28f48916690d761e0d8213e2ad.tar.gz
rapier-e1ed90603e618e28f48916690d761e0d8213e2ad.tar.bz2
rapier-e1ed90603e618e28f48916690d761e0d8213e2ad.zip
Merge branch 'master' into collider-builder-debug
Diffstat (limited to 'src/geometry/contact_pair.rs')
-rw-r--r--src/geometry/contact_pair.rs44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs
index 44730a0..c57f98a 100644
--- a/src/geometry/contact_pair.rs
+++ b/src/geometry/contact_pair.rs
@@ -1,6 +1,6 @@
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};
use crate::pipeline::EventHandler;
use crate::prelude::CollisionEventFlags;
use parry::query::ContactManifoldsWorkspace;
@@ -33,12 +33,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 +45,8 @@ impl Default for ContactData {
Self {
impulse: 0.0,
tangent_impulse: na::zero(),
+ warmstart_impulse: 0.0,
+ warmstart_tangent_impulse: na::zero(),
}
}
}
@@ -57,14 +58,14 @@ pub struct IntersectionPair {
/// Are the colliders intersecting?
pub intersecting: bool,
/// Was a `CollisionEvent::Started` emitted for this collider?
- pub(crate) start_event_emited: bool,
+ pub(crate) start_event_emitted: bool,
}
impl IntersectionPair {
pub(crate) fn new() -> Self {
Self {
intersecting: false,
- start_event_emited: false,
+ start_event_emitted: false,
}
}
@@ -76,7 +77,7 @@ impl IntersectionPair {
collider2: ColliderHandle,
events: &dyn EventHandler,
) {
- self.start_event_emited = true;
+ self.start_event_emitted = true;
events.handle_collision_event(
bodies,
colliders,
@@ -93,7 +94,7 @@ impl IntersectionPair {
collider2: ColliderHandle,
events: &dyn EventHandler,
) {
- self.start_event_emited = false;
+ self.start_event_emitted = false;
events.handle_collision_event(
bodies,
colliders,
@@ -114,11 +115,14 @@ pub struct ContactPair {
/// The set of contact manifolds between the two colliders.
///
/// All contact manifold contain themselves contact points between the colliders.
+ /// Note that contact points in the contact manifold do not take into account the
+ /// [`Collider::contact_skin`] which only affects the constraint solver and the
+ /// [`SolverContact`].
pub manifolds: Vec<ContactManifold>,
/// Is there any active contact in this contact pair?
pub has_any_active_contact: bool,
/// Was a `CollisionEvent::Started` emitted for this collider?
- pub(crate) start_event_emited: bool,
+ pub(crate) start_event_emitted: bool,
pub(crate) workspace: Option<ContactManifoldsWorkspace>,
}
@@ -129,7 +133,7 @@ impl ContactPair {
collider2,
has_any_active_contact: false,
manifolds: Vec::new(),
- start_event_emited: false,
+ start_event_emitted: false,
workspace: None,
}
}
@@ -206,7 +210,7 @@ impl ContactPair {
colliders: &ColliderSet,
events: &dyn EventHandler,
) {
- self.start_event_emited = true;
+ self.start_event_emitted = true;
events.handle_collision_event(
bodies,
@@ -222,7 +226,7 @@ impl ContactPair {
colliders: &ColliderSet,
events: &dyn EventHandler,
) {
- self.start_event_emited = false;
+ self.start_event_emitted = false;
events.handle_collision_event(
bodies,
@@ -299,6 +303,10 @@ pub struct SolverContact {
pub tangent_velocity: Vector<Real>,
/// Whether or not this contact existed during the last timestep.
pub is_new: bool,
+ /// Impulse used to warmstart the solve for the normal constraint.
+ pub warmstart_impulse: Real,
+ /// Impulse used to warmstart the solve for the friction constraints.
+ pub warmstart_tangent_impulse: TangentImpulse<Real>,
}
impl SolverContact {
@@ -351,16 +359,10 @@ impl ContactManifoldData {
pub trait ContactManifoldExt {
/// Computes the sum of all the impulses applied by contacts from this contact manifold.
fn total_impulse(&self) -> Real;
- /// Computes the maximum impulse applied by contacts from this contact manifold.
- fn max_impulse(&self) -> Real;
}
impl ContactManifoldExt for ContactManifold {
fn total_impulse(&self) -> Real {
self.points.iter().map(|pt| pt.data.impulse).sum()
}
-
- fn max_impulse(&self) -> Real {
- self.points.iter().fold(0.0, |a, pt| a.max(pt.data.impulse))
- }
}