aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2021-03-30 17:08:51 +0200
committerCrozet Sébastien <developer@crozet.re>2021-03-30 17:10:50 +0200
commitd2ee6420538d7ee524f2096995d4f44fcfef4551 (patch)
treea2aa5564fb16830cc224f451f6c56be19d191cf5 /src/geometry
parentc3a0c67272e09d3bb4f80aca145ff580d0172745 (diff)
downloadrapier-d2ee6420538d7ee524f2096995d4f44fcfef4551.tar.gz
rapier-d2ee6420538d7ee524f2096995d4f44fcfef4551.tar.bz2
rapier-d2ee6420538d7ee524f2096995d4f44fcfef4551.zip
CCD: take angular motion and penetration depth into account in various thresholds.
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/collider.rs8
-rw-r--r--src/geometry/contact_pair.rs31
2 files changed, 38 insertions, 1 deletions
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index e35603e..11fe5ee 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -660,6 +660,14 @@ impl ColliderBuilder {
/// Sets the initial position (translation and orientation) of the collider to be created,
/// relative to the rigid-body it is attached to.
+ pub fn position_wrt_parent(mut self, pos: Isometry<Real>) -> Self {
+ self.delta = pos;
+ self
+ }
+
+ /// Sets the initial position (translation and orientation) of the collider to be created,
+ /// relative to the rigid-body it is attached to.
+ #[deprecated(note = "Use `.position_wrt_parent` instead.")]
pub fn position(mut self, pos: Isometry<Real>) -> Self {
self.delta = pos;
self
diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs
index ffd5d7f..d4e8ac4 100644
--- a/src/geometry/contact_pair.rs
+++ b/src/geometry/contact_pair.rs
@@ -1,5 +1,5 @@
use crate::dynamics::{BodyPair, RigidBodyHandle};
-use crate::geometry::{ColliderPair, ContactManifold};
+use crate::geometry::{ColliderPair, Contact, ContactManifold};
use crate::math::{Point, Real, Vector};
use parry::query::ContactManifoldsWorkspace;
@@ -76,6 +76,35 @@ impl ContactPair {
workspace: None,
}
}
+
+ /// Finds the contact with the smallest signed distance.
+ ///
+ /// If the colliders involved in this contact pair are penetrating, then
+ /// this returns the contact with the largest penetration depth.
+ ///
+ /// Returns a reference to the contact, as well as the contact manifold
+ /// it is part of.
+ pub fn find_deepest_contact(&self) -> Option<(&ContactManifold, &Contact)> {
+ let mut deepest = None;
+
+ for m2 in &self.manifolds {
+ let deepest_candidate = m2.find_deepest_contact();
+
+ deepest = match (deepest, deepest_candidate) {
+ (_, None) => deepest,
+ (None, Some(c2)) => Some((m2, c2)),
+ (Some((m1, c1)), Some(c2)) => {
+ if c1.dist <= c2.dist {
+ Some((m1, c1))
+ } else {
+ Some((m2, c2))
+ }
+ }
+ }
+ }
+
+ deepest
+ }
}
#[derive(Clone, Debug)]