Merge pull request #73 from dimforge/mass_props_setter

Add a RigidBody::set_mass_properties method.
This commit is contained in:
Sébastien Crozet
2020-12-02 11:48:23 +01:00
committed by GitHub
2 changed files with 19 additions and 0 deletions

View File

@@ -1,3 +1,9 @@
## v0.4.2
- Fix a bug in angular inertia tensor computation that could cause rotations not to
work properly.
- Add `RigidBody::set_mass_properties` to set the mass properties of an already-constructed
rigid-body.
## v0.4.1 ## v0.4.1
- The `RigidBodyBuilder::principal_inertia` method has been deprecated and renamed to - The `RigidBodyBuilder::principal_inertia` method has been deprecated and renamed to
`principal_angular_inertia` for clarity. `principal_angular_inertia` for clarity.

View File

@@ -142,6 +142,19 @@ impl RigidBody {
&self.mass_properties &self.mass_properties
} }
/// Sets the rigid-body's mass properties.
///
/// If `wake_up` is `true` then the rigid-body will be woken up if it was
/// put to sleep because it did not move for a while.
#[inline]
pub fn set_mass_properties(&mut self, props: MassProperties, wake_up: bool) {
if self.is_dynamic() && wake_up {
self.wake_up(true);
}
self.mass_properties = props;
}
/// The handles of colliders attached to this rigid body. /// The handles of colliders attached to this rigid body.
pub fn colliders(&self) -> &[ColliderHandle] { pub fn colliders(&self) -> &[ColliderHandle] {
&self.colliders[..] &self.colliders[..]