Fix rigid-body mass-properties being incorrect after disable/enable
This commit is contained in:
@@ -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) {
|
if changes.contains(RigidBodyChanges::ENABLED_OR_DISABLED) {
|
||||||
// Propagate the rigid-body’s enabled/disable status to its colliders.
|
// Propagate the rigid-body’s enabled/disable status to its colliders.
|
||||||
for handle in rb.colliders.0.iter() {
|
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.ids = ids;
|
||||||
rb.activation = activation;
|
rb.activation = activation;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user