Trait jumpy::core::physics::rapier::EventHandler

pub trait EventHandler: Send + Sync {
    // Required methods
    fn handle_collision_event(
        &self,
        bodies: &RigidBodySet,
        colliders: &ColliderSet,
        event: CollisionEvent,
        contact_pair: Option<&ContactPair>,
    );
    fn handle_contact_force_event(
        &self,
        dt: f32,
        bodies: &RigidBodySet,
        colliders: &ColliderSet,
        contact_pair: &ContactPair,
        total_force_magnitude: f32,
    );
}
Expand description

Trait implemented by structures responsible for handling events generated by the physics engine.

Implementors of this trait will typically collect these events for future processing.

Required Methods§

fn handle_collision_event( &self, bodies: &RigidBodySet, colliders: &ColliderSet, event: CollisionEvent, contact_pair: Option<&ContactPair>, )

Handle a collision event.

A collision event is emitted when the state of intersection between two colliders changes. At least one of the involved colliders must have the ActiveEvents::COLLISION_EVENTS flag set.

§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 to None if at least one of the collider is a sensor (in which case no contact information is ever computed).

fn handle_contact_force_event( &self, dt: f32, bodies: &RigidBodySet, colliders: &ColliderSet, contact_pair: &ContactPair, total_force_magnitude: f32, )

Handle a force event.

A force event is generated whenever the total force magnitude applied between two colliders is > Collider::contact_force_event_threshold value of any of these colliders with the ActiveEvents::CONTACT_FORCE_EVENTS flag set.

The “total force magnitude” here means “the sum of the magnitudes of the forces applied at all the contact points in a contact pair”. Therefore, if the contact pair involves two forces {0.0, 1.0, 0.0} and {0.0, -1.0, 0.0}, then the total force magnitude tested against the contact_force_event_threshold is 2.0 even if the sum of these forces is actually the zero vector.

Implementations on Foreign Types§

§

impl EventHandler for ()

§

fn handle_collision_event( &self, _bodies: &RigidBodySet, _colliders: &ColliderSet, _event: CollisionEvent, _contact_pair: Option<&ContactPair>, )

§

fn handle_contact_force_event( &self, _dt: f32, _bodies: &RigidBodySet, _colliders: &ColliderSet, _contact_pair: &ContactPair, _total_force_magnitude: f32, )

Implementors§

source§

impl EventHandler for &mut CollisionCache

Update the collision cache with rapier collision events.

§

impl EventHandler for ChannelEventCollector