Merge pull request #390 from dimforge/auto-mass-props

Auto-update a rigid-body’s world mass-properties when the user sets their position
This commit is contained in:
Sébastien Crozet
2022-08-25 11:09:00 +02:00
committed by GitHub

View File

@@ -666,6 +666,9 @@ impl RigidBody {
self.pos.position.translation.vector = translation; self.pos.position.translation.vector = translation;
self.pos.next_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? // TODO: Do we really need to check that the body isn't dynamic?
if wake_up && self.is_dynamic() { if wake_up && self.is_dynamic() {
self.wake_up(true) self.wake_up(true)
@@ -687,6 +690,9 @@ impl RigidBody {
self.pos.position.rotation = rotation; self.pos.position.rotation = rotation;
self.pos.next_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? // TODO: Do we really need to check that the body isn't dynamic?
if wake_up && self.is_dynamic() { if wake_up && self.is_dynamic() {
self.wake_up(true) self.wake_up(true)
@@ -709,6 +715,9 @@ impl RigidBody {
self.pos.position = pos; self.pos.position = pos;
self.pos.next_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? // TODO: Do we really need to check that the body isn't dynamic?
if wake_up && self.is_dynamic() { if wake_up && self.is_dynamic() {
self.wake_up(true) self.wake_up(true)