diff options
Diffstat (limited to 'src/dynamics')
| -rw-r--r-- | src/dynamics/rigid_body.rs | 23 | ||||
| -rw-r--r-- | src/dynamics/rigid_body_components.rs | 3 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs index 5eca5a2..085ee0c 100644 --- a/src/dynamics/rigid_body.rs +++ b/src/dynamics/rigid_body.rs @@ -36,6 +36,7 @@ pub struct RigidBody { pub(crate) body_type: RigidBodyType, /// The dominance group this rigid-body is part of. pub(crate) dominance: RigidBodyDominance, + pub(crate) enabled: bool, /// User-defined data associated to this rigid-body. pub user_data: u128, } @@ -62,6 +63,7 @@ impl RigidBody { changes: RigidBodyChanges::all(), body_type: RigidBodyType::Dynamic, dominance: RigidBodyDominance::default(), + enabled: true, user_data: 0, } } @@ -71,6 +73,17 @@ impl RigidBody { self.ids = Default::default(); } + /// Is this rigid-body enabled? + pub fn is_enabled(&self) -> bool { + self.enabled + } + + /// Sets whether or not this rigid-body is enabled. + pub fn set_enabled(&mut self, enabled: bool) { + self.changes |= RigidBodyChanges::ENABLED; + self.enabled = enabled; + } + /// The activation status of this rigid-body. pub fn activation(&self) -> &RigidBodyActivation { &self.activation @@ -869,6 +882,8 @@ pub struct RigidBodyBuilder { /// /// CCD prevents tunneling, but may still allow limited interpenetration of colliders. pub ccd_enabled: bool, + /// Is this rigid-body enabled after its creation? + pub enabled: bool, /// The dominance group of the rigid-body to be built. pub dominance_group: i8, /// An arbitrary user-defined 128-bit integer associated to the rigid-bodies built by this builder. @@ -891,6 +906,7 @@ impl RigidBodyBuilder { can_sleep: true, sleeping: false, ccd_enabled: false, + enabled: true, dominance_group: 0, user_data: 0, } @@ -1037,6 +1053,12 @@ impl RigidBodyBuilder { self } + /// Is this rigid-body enabled after its creation? + pub fn enabled(mut self, is_enabled: bool) -> self { + self.enabled = is_enabled; + self + } + /// Sets the additional mass of the rigid-body being built. /// /// This is only the "additional" mass because the total mass of the rigid-body is @@ -1167,6 +1189,7 @@ impl RigidBodyBuilder { rb.vels.linvel = self.linvel; rb.vels.angvel = self.angvel; rb.body_type = self.body_type; + rb.enabled = self.enabled; rb.user_data = self.user_data; if self.additional_mass_properties != MassProperties::default() { diff --git a/src/dynamics/rigid_body_components.rs b/src/dynamics/rigid_body_components.rs index 3d35d17..ec20a6e 100644 --- a/src/dynamics/rigid_body_components.rs +++ b/src/dynamics/rigid_body_components.rs @@ -73,7 +73,6 @@ pub enum RigidBodyType { /// modified by the user and is independent from any contact or joint it is involved in. KinematicVelocityBased = 3, // Semikinematic, // A kinematic that performs automatic CCD with the fixed environment to avoid traversing it? - // Disabled, } impl RigidBodyType { @@ -110,6 +109,8 @@ bitflags::bitflags! { const TYPE = 1 << 4; /// Flag indicating that the `RigidBodyDominance` component of this rigid-body has been modified. const DOMINANCE = 1 << 5; + /// Flag indicating that the `RigidBody::enabled` status was changed. + const ENABLED = 1 << 6; } } |
