Fix user-change handling for colliders as well as disabled colliders (#900)

* feat: add debug-demo for disabling a collider

* feat: add a simple debug-demo with two cubes

* feat: rename RigidBodyChangnes::MODIFIED and ColliderChanges::MODIFIED to ::IN_MODIFIED_SET

* feat: render debug-colliders with a different color with the debug-renderer

* chore: wire up new examples to the testbed

* fix colliders user-modification being ignored after the first step

* fix broad-phase still taking into account disabled colliders with enabled dynamic rigid-bodies

* chore: update changelog

* fix cargo doc
This commit is contained in:
Sébastien Crozet
2025-11-14 09:35:02 +01:00
committed by GitHub
parent a68d0c600b
commit ef5dcaccaf
11 changed files with 146 additions and 26 deletions

View File

@@ -69,10 +69,6 @@ impl BroadPhaseBvh {
/// sent previously and no `RemovePair` happened since then). Sending redundant events is allowed
/// but can result in a slight computational overhead.
///
/// The `colliders` set is mutable only to provide access to
/// [`collider.set_internal_broad_phase_proxy_index`]. Other properties of the collider should
/// **not** be modified during the broad-phase update.
///
/// # Parameters
/// - `params`: the integration parameters governing the simulation.
/// - `colliders`: the set of colliders. Change detection with `collider.needs_broad_phase_update()`

View File

@@ -35,8 +35,8 @@ bitflags::bitflags! {
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
/// Flags describing how the collider has been modified by the user.
pub struct ColliderChanges: u32 {
/// Flag indicating that any component of the collider has been modified.
const MODIFIED = 1 << 0;
/// Flag indicating that the collider handle is in the changed collider set.
const IN_MODIFIED_SET = 1 << 0;
/// Flag indicating that the density or mass-properties of this collider was changed.
const LOCAL_MASS_PROPERTIES = 1 << 1; // => RigidBody local mass-properties update.
/// Flag indicating that the `ColliderParent` component of the collider has been modified.

View File

@@ -11,12 +11,12 @@ pub type ModifiedColliders = ModifiedObjects<ColliderHandle, Collider>;
impl HasModifiedFlag for Collider {
#[inline]
fn has_modified_flag(&self) -> bool {
self.changes.contains(ColliderChanges::MODIFIED)
self.changes.contains(ColliderChanges::IN_MODIFIED_SET)
}
#[inline]
fn set_modified_flag(&mut self) {
self.changes |= ColliderChanges::MODIFIED;
self.changes |= ColliderChanges::IN_MODIFIED_SET;
}
}