Make sensors not contribute to mass properties #381
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Similar to #355 by @yrns, but without special casing
ColliderDensity
defaults, and implemented with observers.Sensor colliders currently contribute to the mass properties of rigid bodies. This differs from most peoples' expectations, and is also different from many existing engines such as Godot and Unity. Sensor colliders should have no impact on the physics simulation.
Solution
Sensor
component is added to an entity, remove the collider's contribution on the rigid body's mass properties.Sensor
component is removed from an entity, add the collider's mass properties to the rigid body's mass properties.Testing
There is a test to make sure that the mass properties of a rigid body are updated accordingly when the
Sensor
component is first added and then removed from a collider.Migration Guide
Colliders with the
Sensor
component no longer contribute to the mass properties of rigid bodies. You can add mass for them by adding another collider that is not a sensor, or by manually adding mass properties with theMassPropertiesBundle
or its components.Additionally, the mass properties of
Sensor
colliders are no longer updated automatically, unless theSensor
component is removed.