aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dynamics/rigid_body.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index cf52c1f..24e9754 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -305,20 +305,26 @@ impl RigidBody {
self.ccd.ccd_active
}
- /// Sets the rigid-body's initial mass properties.
+ /// Sets the rigid-body's additional 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.mprops.local_mprops != props {
- if self.is_dynamic() && wake_up {
- self.wake_up(true);
- }
+ pub fn set_additional_mass_properties(&mut self, props: MassProperties, wake_up: bool) {
+ if let Some(add_mprops) = &mut self.mprops.additional_local_mprops {
+ self.mprops.local_mprops += props;
+ self.mprops.local_mprops -= **add_mprops;
+ **add_mprops = props;
+ } else {
+ self.mprops.additional_local_mprops = Some(Box::new(props));
+ self.mprops.local_mprops += props;
+ }
- self.mprops.local_mprops = props;
- self.update_world_mass_properties();
+ if self.is_dynamic() && wake_up {
+ self.wake_up(true);
}
+
+ self.update_world_mass_properties();
}
/// The handles of colliders attached to this rigid body.