From d73508602eb15088c05b4738d1d87c60e37b3b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Thu, 25 Aug 2022 10:14:25 +0200 Subject: [PATCH] =?UTF-8?q?Auto-update=20a=20rigid-body=E2=80=99s=20world?= =?UTF-8?q?=20mass-properties=20when=20the=20user=20sets=20their=20positio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dynamics/rigid_body.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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)