Name the contact force events ContactForceEvent instead of CollisionForceEvent
This commit is contained in:
@@ -121,7 +121,7 @@ impl CollisionEvent {
|
|||||||
#[derive(Copy, Clone, PartialEq, Debug, Default)]
|
#[derive(Copy, Clone, PartialEq, Debug, Default)]
|
||||||
/// Event occurring when the sum of the magnitudes of the contact forces
|
/// Event occurring when the sum of the magnitudes of the contact forces
|
||||||
/// between two colliders exceed a threshold.
|
/// between two colliders exceed a threshold.
|
||||||
pub struct CollisionForceEvent {
|
pub struct ContactForceEvent {
|
||||||
/// The first collider involved in the contact.
|
/// The first collider involved in the contact.
|
||||||
pub collider1: ColliderHandle,
|
pub collider1: ColliderHandle,
|
||||||
/// The second collider involved in the contact.
|
/// The second collider involved in the contact.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::dynamics::RigidBodySet;
|
use crate::dynamics::RigidBodySet;
|
||||||
use crate::geometry::{ColliderSet, CollisionEvent, CollisionForceEvent, ContactPair};
|
use crate::geometry::{ColliderSet, CollisionEvent, ContactForceEvent, ContactPair};
|
||||||
use crate::math::Real;
|
use crate::math::Real;
|
||||||
use crossbeam::channel::Sender;
|
use crossbeam::channel::Sender;
|
||||||
|
|
||||||
@@ -89,14 +89,14 @@ impl EventHandler for () {
|
|||||||
/// A collision event handler that collects events into a crossbeam channel.
|
/// A collision event handler that collects events into a crossbeam channel.
|
||||||
pub struct ChannelEventCollector {
|
pub struct ChannelEventCollector {
|
||||||
collision_event_sender: Sender<CollisionEvent>,
|
collision_event_sender: Sender<CollisionEvent>,
|
||||||
contact_force_event_sender: Sender<CollisionForceEvent>,
|
contact_force_event_sender: Sender<ContactForceEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelEventCollector {
|
impl ChannelEventCollector {
|
||||||
/// Initialize a new collision event handler from crossbeam channel senders.
|
/// Initialize a new collision event handler from crossbeam channel senders.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
collision_event_sender: Sender<CollisionEvent>,
|
collision_event_sender: Sender<CollisionEvent>,
|
||||||
contact_force_event_sender: Sender<CollisionForceEvent>,
|
contact_force_event_sender: Sender<ContactForceEvent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
collision_event_sender,
|
collision_event_sender,
|
||||||
@@ -124,11 +124,11 @@ impl EventHandler for ChannelEventCollector {
|
|||||||
contact_pair: &ContactPair,
|
contact_pair: &ContactPair,
|
||||||
total_force_magnitude: Real,
|
total_force_magnitude: Real,
|
||||||
) {
|
) {
|
||||||
let mut result = CollisionForceEvent {
|
let mut result = ContactForceEvent {
|
||||||
collider1: contact_pair.collider1,
|
collider1: contact_pair.collider1,
|
||||||
collider2: contact_pair.collider2,
|
collider2: contact_pair.collider2,
|
||||||
total_force_magnitude,
|
total_force_magnitude,
|
||||||
..CollisionForceEvent::default()
|
..ContactForceEvent::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
for m in &contact_pair.manifolds {
|
for m in &contact_pair.manifolds {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use rapier::dynamics::{
|
|||||||
CCDSolver, ImpulseJointSet, IntegrationParameters, IslandManager, MultibodyJointSet,
|
CCDSolver, ImpulseJointSet, IntegrationParameters, IslandManager, MultibodyJointSet,
|
||||||
RigidBodySet,
|
RigidBodySet,
|
||||||
};
|
};
|
||||||
use rapier::geometry::{BroadPhase, ColliderSet, CollisionEvent, CollisionForceEvent, NarrowPhase};
|
use rapier::geometry::{BroadPhase, ColliderSet, CollisionEvent, ContactForceEvent, NarrowPhase};
|
||||||
use rapier::math::{Real, Vector};
|
use rapier::math::{Real, Vector};
|
||||||
use rapier::pipeline::{PhysicsHooks, PhysicsPipeline, QueryPipeline};
|
use rapier::pipeline::{PhysicsHooks, PhysicsPipeline, QueryPipeline};
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ impl PhysicsState {
|
|||||||
|
|
||||||
pub struct PhysicsEvents {
|
pub struct PhysicsEvents {
|
||||||
pub collision_events: Receiver<CollisionEvent>,
|
pub collision_events: Receiver<CollisionEvent>,
|
||||||
pub contact_force_events: Receiver<CollisionForceEvent>,
|
pub contact_force_events: Receiver<ContactForceEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PhysicsEvents {
|
impl PhysicsEvents {
|
||||||
|
|||||||
Reference in New Issue
Block a user