Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sensors not contribute to mass properties #381

Merged
merged 5 commits into from
Jun 23, 2024

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Jun 22, 2024

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

  • When the Sensor component is added to an entity, remove the collider's contribution on the rigid body's mass properties.
  • When the 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 the MassPropertiesBundle or its components.

Additionally, the mass properties of Sensor colliders are no longer updated automatically, unless the Sensor component is removed.

@Jondolf Jondolf added the bugfix label Jun 22, 2024
@Jondolf Jondolf added the C-Breaking-Change This change removes or changes behavior or APIs, requiring users to adapt label Jun 22, 2024
src/plugins/collision/collider/mod.rs Outdated Show resolved Hide resolved
src/plugins/collision/collider/backend.rs Outdated Show resolved Hide resolved
src/plugins/collision/collider/backend.rs Outdated Show resolved Hide resolved
@Jondolf Jondolf merged commit 5648560 into bevy-0.14 Jun 23, 2024
4 checks passed
@Jondolf Jondolf deleted the no-sensor-mass-properties branch June 23, 2024 13:48
@Jondolf Jondolf added C-Bug Something isn't working A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on and removed bugfix labels Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Dynamics Relates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so on C-Breaking-Change This change removes or changes behavior or APIs, requiring users to adapt C-Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants