aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2020-12-02 11:48:23 +0100
committerGitHub <noreply@github.com>2020-12-02 11:48:23 +0100
commitd9695ca9774415589c645e06f31b0e1a46d29166 (patch)
tree778a00eea7548d416043ad77539a1682116d377c
parentc2b1fa19f89b4aa6a6f113f1e480ee2648f75be2 (diff)
parentaada91966a02fbbbc5359cf74bb0401aac44ba8e (diff)
downloadrapier-d9695ca9774415589c645e06f31b0e1a46d29166.tar.gz
rapier-d9695ca9774415589c645e06f31b0e1a46d29166.tar.bz2
rapier-d9695ca9774415589c645e06f31b0e1a46d29166.zip
Merge pull request #73 from dimforge/mass_props_setter
Add a RigidBody::set_mass_properties method.
-rw-r--r--CHANGELOG.md6
-rw-r--r--src/dynamics/rigid_body.rs13
2 files changed, 19 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c780bd5..fe6e56e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
- The `RigidBodyBuilder::principal_inertia` method has been deprecated and renamed to
`principal_angular_inertia` for clarity.
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index 86a126f..5128b6f 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -142,6 +142,19 @@ impl RigidBody {
&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.
pub fn colliders(&self) -> &[ColliderHandle] {
&self.colliders[..]