Skip to content

validate multibody joint insertion before creating any root multibody - #1056

Open
dundysm wants to merge 1 commit into
dimforge:masterfrom
dundysm:multibody-insert-validate-first
Open

dundysm wants to merge 1 commit into
dimforge:masterfrom
dundysm:multibody-insert-validate-first

Conversation

@dundysm

@dundysm dundysm commented Oct 31, 2026

Copy link
Copy Markdown

fixes #1022

MultibodyJointSet::do_insert created a root multibody and a connectivity graph node for every endpoint not yet in the set, and only then checked whether the insertion was valid. so:

  • insert(body, body, ..) created two provisional roots, merged them and returned Some for a self joint;
  • each rejected insert(fresh, child, ..) where child already has a parent returned None but left a root multibody and a graph node behind for fresh.

this does the checks first, from the existing rb2mb entries: identical handles are rejected, a body2 that already has a parent is rejected, and two bodies already in the same multibody are rejected. the provisional roots are only created once the insertion is known to succeed; the rest of the function is unchanged.

added crates/rapier3d/tests/issue_1022_multibody_rejected_insert.rs; on master the self joint is accepted and ten rejected inserts leave 11 multibodies instead of 1; both tests pass with the change. cargo test passes for rapier3d and rapier2d, and clippy is clean.

Signed-off-by: Dundy Pasupuleti <dundysm@gmail.com>

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.

Rejected multibody insertion leaks topology and accepts a same-body self-joint

1 participant