aboutsummaryrefslogtreecommitdiff
path: root/src/pipeline
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/pipeline
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/pipeline')
-rw-r--r--src/pipeline/event_handler.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/pipeline/event_handler.rs b/src/pipeline/event_handler.rs
index 5fa90c6..f08a383 100644
--- a/src/pipeline/event_handler.rs
+++ b/src/pipeline/event_handler.rs
@@ -23,18 +23,18 @@ impl Default for ActiveEvents {
pub trait EventHandler: Send + Sync {
/// Handle a collision event.
///
- /// A intersection event is emitted when the state of intersection between two colliders changes.
- fn handle_intersection_event(&self, event: CollisionEvent);
- /// Handle a contact event.
+ /// A collision event is emitted when the state of intersection between two colliders changes.
///
- /// A contact event is emitted when two collider start or stop touching, independently from the
- /// number of contact points involved.
- fn handle_contact_event(&self, event: CollisionEvent, contact_pair: &ContactPair);
+ /// # Parameters
+ /// * `event` - The collision event.
+ /// * `contact_pair` - The current state of contacts between the two colliders. This is set ot `None`
+ /// if at least one of the collider is a sensor (in which case no contact information
+ /// is ever computed).
+ fn handle_collision_event(&self, event: CollisionEvent, contact_pair: Option<&ContactPair>);
}
impl EventHandler for () {
- fn handle_intersection_event(&self, _event: CollisionEvent) {}
- fn handle_contact_event(&self, _event: CollisionEvent, _contact_pair: &ContactPair) {}
+ fn handle_collision_event(&self, _event: CollisionEvent, _contact_pair: Option<&ContactPair>) {}
}
/// A collision event handler that collects events into a crossbeam channel.
@@ -50,11 +50,7 @@ impl ChannelEventCollector {
}
impl EventHandler for ChannelEventCollector {
- fn handle_intersection_event(&self, event: CollisionEvent) {
- let _ = self.event_sender.send(event);
- }
-
- fn handle_contact_event(&self, event: CollisionEvent, _: &ContactPair) {
+ fn handle_collision_event(&self, event: CollisionEvent, _: Option<&ContactPair>) {
let _ = self.event_sender.send(event);
}
}