aboutsummaryrefslogtreecommitdiff
path: root/src/pipeline
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-04-28 13:02:43 +0200
committerSébastien Crozet <developer@crozet.re>2022-04-28 13:03:14 +0200
commitae40f4cd7e55dd81955cd329f4d45bba040ba012 (patch)
treec3ab6c3bbb01cbafd856cc3a5b95441ea6b58f17 /src/pipeline
parent007406ce20ff3957dbc18e1a7777d6385dc86d5f (diff)
downloadrapier-ae40f4cd7e55dd81955cd329f4d45bba040ba012.tar.gz
rapier-ae40f4cd7e55dd81955cd329f4d45bba040ba012.tar.bz2
rapier-ae40f4cd7e55dd81955cd329f4d45bba040ba012.zip
Add collision event flags
Diffstat (limited to 'src/pipeline')
-rw-r--r--src/pipeline/event_handler.rs30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/pipeline/event_handler.rs b/src/pipeline/event_handler.rs
index f08a383..f6c33ec 100644
--- a/src/pipeline/event_handler.rs
+++ b/src/pipeline/event_handler.rs
@@ -1,4 +1,5 @@
-use crate::geometry::{CollisionEvent, ContactPair};
+use crate::dynamics::RigidBodySet;
+use crate::geometry::{ColliderSet, CollisionEvent, ContactPair};
use crossbeam::channel::Sender;
bitflags::bitflags! {
@@ -27,14 +28,29 @@ pub trait EventHandler: Send + Sync {
///
/// # Parameters
/// * `event` - The collision event.
+ /// * `bodies` - The set of rigid-bodies.
+ /// * `colliders` - The set of colliders.
/// * `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>);
+ fn handle_collision_event(
+ &self,
+ bodies: &RigidBodySet,
+ colliders: &ColliderSet,
+ event: CollisionEvent,
+ contact_pair: Option<&ContactPair>,
+ );
}
impl EventHandler for () {
- fn handle_collision_event(&self, _event: CollisionEvent, _contact_pair: Option<&ContactPair>) {}
+ fn handle_collision_event(
+ &self,
+ _bodies: &RigidBodySet,
+ _colliders: &ColliderSet,
+ _event: CollisionEvent,
+ _contact_pair: Option<&ContactPair>,
+ ) {
+ }
}
/// A collision event handler that collects events into a crossbeam channel.
@@ -50,7 +66,13 @@ impl ChannelEventCollector {
}
impl EventHandler for ChannelEventCollector {
- fn handle_collision_event(&self, event: CollisionEvent, _: Option<&ContactPair>) {
+ fn handle_collision_event(
+ &self,
+ _bodies: &RigidBodySet,
+ _colliders: &ColliderSet,
+ event: CollisionEvent,
+ _: Option<&ContactPair>,
+ ) {
let _ = self.event_sender.send(event);
}
}