diff options
| author | Sébastien Crozet <developer@crozet.re> | 2023-01-22 10:00:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-22 10:00:18 +0100 |
| commit | c18276a2fb916f3273e0f9c952b0ed55232ae9c6 (patch) | |
| tree | e27c68a576c04d519ac5d2e447d043108ffbf83c | |
| parent | 155fb9b1c08a2c86fb36462d953790befe965164 (diff) | |
| parent | de59c6b58c53535d4dd87a6de552d89d30984ea2 (diff) | |
| download | rapier-c18276a2fb916f3273e0f9c952b0ed55232ae9c6.tar.gz rapier-c18276a2fb916f3273e0f9c952b0ed55232ae9c6.tar.bz2 rapier-c18276a2fb916f3273e0f9c952b0ed55232ae9c6.zip | |
Merge pull request #439 from dimforge/rb-disable-enable-mprops
Fix rigid-body mass-properties being incorrect after disable/enable
| -rw-r--r-- | src/pipeline/user_changes.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/pipeline/user_changes.rs b/src/pipeline/user_changes.rs index eeda97a..a047256 100644 --- a/src/pipeline/user_changes.rs +++ b/src/pipeline/user_changes.rs @@ -161,16 +161,6 @@ pub(crate) fn handle_user_changes_to_rigid_bodies( } } - if changes - .intersects(RigidBodyChanges::LOCAL_MASS_PROPERTIES | RigidBodyChanges::COLLIDERS) - { - rb.mprops.recompute_mass_properties_from_colliders( - colliders, - &rb.colliders, - &rb.pos.position, - ); - } - if changes.contains(RigidBodyChanges::ENABLED_OR_DISABLED) { // Propagate the rigid-body’s enabled/disable status to its colliders. for handle in rb.colliders.0.iter() { @@ -208,6 +198,19 @@ pub(crate) fn handle_user_changes_to_rigid_bodies( } } + // NOTE: recompute the mass-properties AFTER dealing with the rigid-body changes + // that imply a collider change (in particular, after propagation of the + // enabled/disabled status). + if changes + .intersects(RigidBodyChanges::LOCAL_MASS_PROPERTIES | RigidBodyChanges::COLLIDERS) + { + rb.mprops.recompute_mass_properties_from_colliders( + colliders, + &rb.colliders, + &rb.pos.position, + ); + } + rb.ids = ids; rb.activation = activation; } |
