Allow disabling colliders, rigid-bodies and impulse joints

This commit is contained in:
Sébastien Crozet
2022-11-19 16:05:46 +01:00
parent c600549aac
commit 46d976d97b
15 changed files with 408 additions and 107 deletions

View File

@@ -64,6 +64,8 @@ bitflags::bitflags! {
/// This flags is automatically set by the `PhysicsPipeline` when the `RigidBodyChanges::DOMINANCE`
/// or `RigidBodyChanges::TYPE` of the parent rigid-body of this collider is detected.
const PARENT_EFFECTIVE_DOMINANCE = 1 << 7; // NF update.
/// Flag indicating that whether or not the collider is enabled was changed.
const ENABLED_OR_DISABLED = 1 << 8; // BF & NF updates.
}
}
@@ -372,6 +374,19 @@ impl Default for ActiveCollisionTypes {
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
/// Enum indicating whether or not a collider is enabled.
pub enum ColliderEnabled {
/// The collider is enabled.
Enabled,
/// The collider wasnt disabled by the user explicitly but it is attached to
/// a disabled rigid-body.
DisabledByParent,
/// The collider is disabled by the user explicitly.
Disabled,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
/// A set of flags for controlling collision/intersection filtering, modification, and events.
@@ -389,6 +404,8 @@ pub struct ColliderFlags {
pub active_hooks: ActiveHooks,
/// The events enabled for this collider.
pub active_events: ActiveEvents,
/// Whether or not the collider is enabled.
pub enabled: ColliderEnabled,
}
impl Default for ColliderFlags {
@@ -399,6 +416,7 @@ impl Default for ColliderFlags {
solver_groups: InteractionGroups::all(),
active_hooks: ActiveHooks::empty(),
active_events: ActiveEvents::empty(),
enabled: ColliderEnabled::Enabled,
}
}
}