aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/mod.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-07-01 14:26:57 +0200
committerGitHub <noreply@github.com>2022-07-01 14:26:57 +0200
commit1ba37b8f635bd79db2e48b07c038723f9e8c172f (patch)
treefa31ce984ba86601a3bfbe9b2b231c02ba08c45a /src/geometry/mod.rs
parent8546434f35d8a8a3e6e6bb09c7985ab409a17d8d (diff)
parentd3ca956565dc361fe5583dc756f10de7c2ee1bbd (diff)
downloadrapier-1ba37b8f635bd79db2e48b07c038723f9e8c172f.tar.gz
rapier-1ba37b8f635bd79db2e48b07c038723f9e8c172f.tar.bz2
rapier-1ba37b8f635bd79db2e48b07c038723f9e8c172f.zip
Merge pull request #353 from dimforge/force-events
Add force reporting
Diffstat (limited to 'src/geometry/mod.rs')
-rw-r--r--src/geometry/mod.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs
index 34d3707..48d71f8 100644
--- a/src/geometry/mod.rs
+++ b/src/geometry/mod.rs
@@ -16,6 +16,8 @@ pub use self::collider_set::ColliderSet;
pub use parry::query::TrackedContact;
+use crate::math::{Real, Vector};
+
/// A contact between two colliders.
pub type Contact = parry::query::TrackedContact<ContactData>;
/// A contact manifold between two colliders.
@@ -116,6 +118,28 @@ impl CollisionEvent {
}
}
+#[derive(Copy, Clone, PartialEq, Debug, Default)]
+/// Event occurring when the sum of the magnitudes of the contact forces
+/// between two colliders exceed a threshold.
+pub struct CollisionForceEvent {
+ /// The first collider involved in the contact.
+ pub collider1: ColliderHandle,
+ /// The second collider involved in the contact.
+ pub collider2: ColliderHandle,
+ /// The sum of all the forces between the two colliders.
+ pub total_force: Vector<Real>,
+ /// The sum of the magnitudes of each force between the two colliders.
+ ///
+ /// Note that this is **not** the same as the magnitude of `self.total_force`.
+ /// Here we are summing the magnitude of all the forces, instead of taking
+ /// the magnitude of their sum.
+ pub total_force_magnitude: Real,
+ /// The world-space (unit) direction of the force with strongest magnitude.
+ pub max_force_direction: Vector<Real>,
+ /// The magnitude of the largest force at a contact point of this contact pair.
+ pub max_force_magnitude: Real,
+}
+
pub(crate) use self::broad_phase_multi_sap::SAPProxyIndex;
pub(crate) use self::narrow_phase::ContactManifoldIndex;
pub(crate) use parry::partitioning::QBVH;