-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Objective Logic related to mass properties is currently a bit scattered around (`PreparePlugin`, `ColliderBackendPlugin`...), and there is also no way to opt out of automatic updating of mass properties. It would be nice to encapsulate this logic inside a single plugin, especially as we rework mass properties (#499) and add more APIs and functionality for working with mass. This also contributes to the goal of removing `PreparePlugin`, which is currently full of various miscallaneous and unrelated logic. ## Solution Add a `MassPropertyPlugin`. It updates mass properties of rigid bodies when colliders are added or removed, or when their `ColliderMassProperties` are updated. It also logs warnings for invalid mass properties, and updates `GlobalAngularInertia`. Previously, the logic for updating mass properties based on `ColliderMassProperties` changes was heavily tied to the `ColliderMassProperties` update logic in `ColliderBackendPlugin`, because it required knowing both the previous and new mass properties of the collider. Same for mass property updates caused by adding or removing colliders. Now, it doesn't directly change the body's mass properties, but instead triggers an `OnColliderMassPropertiesChanged` event that the `MassPropertyPlugin` (and users) can react to. This makes the collider logic only responsible for managing `ColliderMassProperties`, and the logic for rigid bodies is self-contained. --- ## Migration Guide The `MassPropertyPlugin` is now needed to update mass properties automatically based on attached colliders. Most apps won't need to add it manually, as it is included in the `PhysicsPlugins` plugin group by default.
- Loading branch information
Showing
9 changed files
with
1,396 additions
and
1,331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.