Skip to content

Fix inherited enabled state when reparenting a collider - #1040

Open
RoboX2020 wants to merge 1 commit into
dimforge:masterfrom
RoboX2020:fix/collider-reparent-enabled
Open

RoboX2020 wants to merge 1 commit into
dimforge:masterfrom
RoboX2020:fix/collider-reparent-enabled

Conversation

@RoboX2020

Copy link
Copy Markdown

Fixes #1023.

ColliderSet::set_parent rewired the collider but never recomputed the inherited enabled projection from the new parent. A collider moved from a disabled body to an enabled body stayed DisabledByParent, and one moved onto a disabled body could stay Enabled, so collision participation depended on the previous parent instead of the final graph.

The fix recomputes the inherited state from the new parent (or from standalone status when detached) whenever the collider is not explicitly Disabled, and sets ColliderChanges::ENABLED_OR_DISABLED when the projection changes. An explicitly disabled collider stays disabled, matching how body enable/disable already treats it.

Regression tests in src/geometry/collider_set.rs cover reparenting disabled->enabled, enabled->disabled, detach to standalone, and preservation of an explicitly disabled collider across all three transitions. The tests are compiled into both rapier2d and rapier3d.

Testing:

  • The reporter's exact reproduction from Collider reparenting retains the old parent's inherited enabled state #1023 fails on master (475caa3) before the fix and passes with it.
  • Library suites pass: rapier3d 83/83, rapier2d 66/66, including the new tests in both dimensions. rapier3d doctests: 92 passed, 15 ignored.
  • Full default cargo test runs were attempted but exceeded the time budget in long-running existing integration cases (3D soft_bodies, 2D heightfield_solver_graph); no assertion failure occurred before the timeout.
  • rapier2d doctests fail to build because shared doc examples import rapier3d, which is unavailable to the rapier2d doctest harness; that error is in src/data/arena.rs, untouched by this change.

Added logic to manage collider enabled state based on parent.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collider reparenting retains the old parent's inherited enabled state

1 participant