Skip to content

Conversation

@Jondolf
Copy link
Member

@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.

Co-authored-by: Al McElrath <hello@yrns.org>
@Jondolf Jondolf added the bugfix label Jun 22, 2024
@Jondolf Jondolf added the M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide label Jun 22, 2024
@Jondolf Jondolf merged commit 5648560 into bevy-0.14 Jun 23, 2024
@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-Bug Something isn't working M-Migration-Guide A breaking change to Avian's public API that needs to be noted in a migration guide

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants