aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-08-25 10:14:25 +0200
committerSébastien Crozet <developer@crozet.re>2022-08-25 10:21:17 +0200
commitd73508602eb15088c05b4738d1d87c60e37b3b21 (patch)
tree75627217e36547a149312fe4d859a925c064b2a7 /src
parent2b5c52a89f65b5d5fec4862d9f047bbdbb3defa8 (diff)
downloadrapier-d73508602eb15088c05b4738d1d87c60e37b3b21.tar.gz
rapier-d73508602eb15088c05b4738d1d87c60e37b3b21.tar.bz2
rapier-d73508602eb15088c05b4738d1d87c60e37b3b21.zip
Auto-update a rigid-body’s world mass-properties when the user sets their position
Diffstat (limited to 'src')
-rw-r--r--src/dynamics/rigid_body.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index ee64f93..9c38eee 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -666,6 +666,9 @@ impl RigidBody {
self.pos.position.translation.vector = translation;
self.pos.next_position.translation.vector = translation;
+ // Update the world mass-properties so torque application remains valid.
+ self.update_world_mass_properties();
+
// TODO: Do we really need to check that the body isn't dynamic?
if wake_up && self.is_dynamic() {
self.wake_up(true)
@@ -687,6 +690,9 @@ impl RigidBody {
self.pos.position.rotation = rotation;
self.pos.next_position.rotation = rotation;
+ // Update the world mass-properties so torque application remains valid.
+ self.update_world_mass_properties();
+
// TODO: Do we really need to check that the body isn't dynamic?
if wake_up && self.is_dynamic() {
self.wake_up(true)
@@ -709,6 +715,9 @@ impl RigidBody {
self.pos.position = pos;
self.pos.next_position = pos;
+ // Update the world mass-properties so torque application remains valid.
+ self.update_world_mass_properties();
+
// TODO: Do we really need to check that the body isn't dynamic?
if wake_up && self.is_dynamic() {
self.wake_up(true)