aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/mod.rs
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-03-20 12:13:32 +0100
committerSébastien Crozet <sebastien@crozet.re>2022-03-20 21:49:16 +0100
commitd38740369c12ff10ffa6ceef438cb1c90c5d3508 (patch)
treee7f37c26c400b93bed96a8c7697c60e2a183ecfa /src/geometry/mod.rs
parent063c638ec5906747e3ca85ee0c5f112c7775f797 (diff)
downloadrapier-d38740369c12ff10ffa6ceef438cb1c90c5d3508.tar.gz
rapier-d38740369c12ff10ffa6ceef438cb1c90c5d3508.tar.bz2
rapier-d38740369c12ff10ffa6ceef438cb1c90c5d3508.zip
Emit collision stopped events after a collider is removed.
Diffstat (limited to 'src/geometry/mod.rs')
-rw-r--r--src/geometry/mod.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs
index 83c687b..5a56f2b 100644
--- a/src/geometry/mod.rs
+++ b/src/geometry/mod.rs
@@ -2,8 +2,9 @@
pub use self::broad_phase_multi_sap::{BroadPhase, BroadPhasePairEvent, ColliderPair};
pub use self::collider_components::*;
-pub use self::contact_pair::{ContactData, ContactManifoldData};
-pub use self::contact_pair::{ContactPair, SolverContact, SolverFlags};
+pub use self::contact_pair::{
+ ContactData, ContactManifoldData, ContactPair, IntersectionPair, SolverContact, SolverFlags,
+};
pub use self::interaction_graph::{
ColliderGraphIndex, InteractionGraph, RigidBodyGraphIndex, TemporaryInteractionIndex,
};
@@ -56,8 +57,11 @@ pub use parry::shape::SharedShape;
pub enum CollisionEvent {
/// Event occurring when two colliders start being in contact (or intersecting)
Started(ColliderHandle, ColliderHandle),
- /// Event occurring when two colliders stop being in contact (or intersecting)
- Stopped(ColliderHandle, ColliderHandle),
+ /// Event occurring when two colliders stop being in contact (or intersecting).
+ ///
+ /// The boolean is set to `true` of this event originates from at least one of
+ /// the colliders being removed from the `ColliderSet`.
+ Stopped(ColliderHandle, ColliderHandle, bool),
}
impl CollisionEvent {
@@ -65,31 +69,31 @@ impl CollisionEvent {
if start {
Self::Started(h1, h2)
} else {
- Self::Stopped(h1, h2)
+ Self::Stopped(h1, h2, false)
}
}
/// Is this a `Started` collision event?
pub fn started(self) -> bool {
- matches!(self, CollisionEvent::Started(_, _))
+ matches!(self, CollisionEvent::Started(..))
}
/// Is this a `Stopped` collision event?
pub fn stopped(self) -> bool {
- matches!(self, CollisionEvent::Stopped(_, _))
+ matches!(self, CollisionEvent::Stopped(..))
}
/// The handle of the first collider involved in this collision event.
pub fn collider1(self) -> ColliderHandle {
match self {
- Self::Started(h, _) | Self::Stopped(h, _) => h,
+ Self::Started(h, _) | Self::Stopped(h, _, _) => h,
}
}
/// The handle of the second collider involved in this collision event.
pub fn collider2(self) -> ColliderHandle {
match self {
- Self::Started(_, h) | Self::Stopped(_, h) => h,
+ Self::Started(_, h) | Self::Stopped(_, h, _) => h,
}
}
}