aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-04-28 13:03:55 +0200
committerSébastien Crozet <developer@crozet.re>2022-04-28 13:03:55 +0200
commit95418c218b387dacbeaa66325e5a321e5106d273 (patch)
treee67c4def5712156f59ad69b451dd4d76a405971c
parentae40f4cd7e55dd81955cd329f4d45bba040ba012 (diff)
downloadrapier-95418c218b387dacbeaa66325e5a321e5106d273.tar.gz
rapier-95418c218b387dacbeaa66325e5a321e5106d273.tar.bz2
rapier-95418c218b387dacbeaa66325e5a321e5106d273.zip
Rename RigidBody::set_mass_properties -> set_additional_mass_properties
-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.