-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Objective Setting the density of a collider is currently unnecessarily verbose and limiting. It requires giving the collider and density to a method that creates the mass property component: ```rust ColliderMassProperties::new_computed(&Collider::ball(0.5), 2.5) ``` This makes it basically impossible to specify the density when the collider isn't known in advance, like for async colliders #190, and the API is just very inconvenient. ## Solution Add a `ColliderDensity` component. The above becomes just this: ```rust ColliderDensity(2.5) ``` Because `ColliderMassProperties` is always overwritten using this density, I also made its properties completely read-only with getter methods. --- ## Changelog - Added `ColliderDensity` - Added `Collider::mass_properties` - Renamed `ColliderMassProperties::new_computed` to `ColliderMassProperties::new` - Made the properties of `ColliderMassProperties` read-only - Updated the documentation ## Migration Guide ```rust // Before let collider = Collider::ball(0.5); commands.spawn(( RigidBody::Dynamic, ColliderMassProperties::new_computed(&collider, 2.5), collider, )); // After commands.spawn(( RigidBody::Dynamic, Collider::ball(0.5), ColliderDensity(2.5), )); ```
- Loading branch information
Showing
6 changed files
with
154 additions
and
35 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
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