Skip to content

Validate the new parent in ColliderSet::set_parent before mutating - #1044

Open
RoboX2020 wants to merge 1 commit into
dimforge:masterfrom
RoboX2020:fix/1021-validate-reparent
Open

RoboX2020 wants to merge 1 commit into
dimforge:masterfrom
RoboX2020:fix/1021-validate-reparent

Conversation

@RoboX2020

Copy link
Copy Markdown

Fixes #1021.

ColliderSet::set_parent removed the collider from its current body's collider list and overwrote the stored parent before validating the requested RigidBodyHandle. Passing a stale or invalid handle left a dangling parent, and the next PhysicsPipeline::step panicked while processing the change.

The method now checks that the requested parent exists first and returns without touching either set when it does not, so an invalid reparent is a no-op.

Regression tests cover a never-valid handle and a stale generational handle (both preserve the existing relationship and survive a step), plus valid reparent and detach behavior. The doc comment notes the new no-op behavior.

Tested: cargo test -p rapier3d 84/84 and cargo test -p rapier2d 66/66.

Added tests for collider reparenting behavior, ensuring that invalid parent handles do not alter existing relationships and standalone colliders remain unaffected.

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.

ColliderSet::set_parent partially commits an invalid body handle and panics on step

1 participant