diff options
| author | Crozet Sébastien <developer@crozet.re> | 2021-06-01 12:36:01 +0200 |
|---|---|---|
| committer | Crozet Sébastien <developer@crozet.re> | 2021-06-01 12:36:01 +0200 |
| commit | 826ce5f014281fd04b7a18238f102f2591d0b255 (patch) | |
| tree | b35c16371dcfac726c2821b7bfd9da21184155bd /src/geometry/collider_components.rs | |
| parent | 1bef66fea941307a7305ddaebdb0abe3d0cb281f (diff) | |
| download | rapier-826ce5f014281fd04b7a18238f102f2591d0b255.tar.gz rapier-826ce5f014281fd04b7a18238f102f2591d0b255.tar.bz2 rapier-826ce5f014281fd04b7a18238f102f2591d0b255.zip | |
Rework the event system
Diffstat (limited to 'src/geometry/collider_components.rs')
| -rw-r--r-- | src/geometry/collider_components.rs | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/src/geometry/collider_components.rs b/src/geometry/collider_components.rs index b63b290..5923a42 100644 --- a/src/geometry/collider_components.rs +++ b/src/geometry/collider_components.rs @@ -2,7 +2,7 @@ use crate::dynamics::{CoefficientCombineRule, MassProperties, RigidBodyHandle}; use crate::geometry::{InteractionGroups, SAPProxyIndex, Shape, SharedShape}; use crate::math::{Isometry, Real}; use crate::parry::partitioning::IndexedData; -use crate::pipeline::PhysicsHooksFlags; +use crate::pipeline::{ActiveEvents, ActiveHooks}; use std::ops::Deref; /// The unique identifier of a collider added to a collider set. @@ -118,7 +118,7 @@ pub type ColliderShape = SharedShape; #[derive(Clone)] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] /// The mass-properties of a collider. -pub enum ColliderMassProperties { +pub enum ColliderMassProps { /// The collider is given a density. /// /// Its actual `MassProperties` are computed automatically with @@ -128,13 +128,19 @@ pub enum ColliderMassProperties { MassProperties(Box<MassProperties>), } -impl Default for ColliderMassProperties { +impl Default for ColliderMassProps { fn default() -> Self { - ColliderMassProperties::Density(1.0) + ColliderMassProps::Density(1.0) } } -impl ColliderMassProperties { +impl From<MassProperties> for ColliderMassProps { + fn from(mprops: MassProperties) -> Self { + ColliderMassProps::MassProperties(Box::new(mprops)) + } +} + +impl ColliderMassProps { /// The mass-properties of this collider. /// /// If `self` is the `Density` variant, then this computes the mass-properties based @@ -242,8 +248,6 @@ pub struct ColliderMaterial { pub friction_combine_rule: CoefficientCombineRule, /// The rule applied to combine the restitution coefficients of two colliders. pub restitution_combine_rule: CoefficientCombineRule, - /// The physics hooks enabled for contact pairs and intersection pairs involving this collider. - pub active_hooks: PhysicsHooksFlags, } impl ColliderMaterial { @@ -264,7 +268,43 @@ impl Default for ColliderMaterial { restitution: 0.0, friction_combine_rule: CoefficientCombineRule::default(), restitution_combine_rule: CoefficientCombineRule::default(), - active_hooks: PhysicsHooksFlags::empty(), + } + } +} + +#[derive(Copy, Clone, Debug)] +#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] +/// A set of flags controlling the active hooks and events for this colliders. +pub struct ColliderFlags { + /// The physics hooks enabled for contact pairs and intersection pairs involving this collider. + pub active_hooks: ActiveHooks, + /// The events enabled for this collider. + pub active_events: ActiveEvents, +} + +impl Default for ColliderFlags { + fn default() -> Self { + Self { + active_hooks: ActiveHooks::empty(), + active_events: ActiveEvents::empty(), + } + } +} + +impl From<ActiveHooks> for ColliderFlags { + fn from(active_hooks: ActiveHooks) -> Self { + Self { + active_hooks, + ..Default::default() + } + } +} + +impl From<ActiveEvents> for ColliderFlags { + fn from(active_events: ActiveEvents) -> Self { + Self { + active_events, + ..Default::default() } } } |
