Skip to content

Clean up associated user constraints when removing a body (#4808) - #4813

Open
Tyagiquamar wants to merge 1 commit into
bulletphysics:masterfrom
Tyagiquamar:fix-remove-body-constraint-cleanup-4808
Open

Tyagiquamar wants to merge 1 commit into
bulletphysics:masterfrom
Tyagiquamar:fix-remove-body-constraint-cleanup-4808

Conversation

@Tyagiquamar

Copy link
Copy Markdown

Summary

Fixes #4808. When removing a body via \CMD_REMOVE_BODY, any user constraints referencing that body (either as parent, child, multi-body, rigid-body, or soft body anchor) were previously left dangling in \m_userConstraints. This could lead to invalid pointer dereferencing or stale constraint lookup on subsequent simulation steps.

Changes

  1. **\PhysicsServerCommandProcessor**:
    • Added helper
      emoveUserConstraintsForBody(int bodyUniqueId, struct SharedMemoryStatus& serverCmd)\ to comprehensively find and clean up all associated user constraints, rigid body constraints, multi-body constraints, and soft body anchors attached to the target body.
    • Populated \m_userConstraintUniqueIds\ in \serverCmd.m_removeObjectArgs\ so client command processor is notified of removed user constraints.
  2. **\PhysicsClientSharedMemory\ & \PhysicsDirect**:
    • Updated client status handlers to remove all returned user constraints from client-side tracking structures when a body is removed.
  3. **\�3RobotSimulatorClientAPI_NoDirect**:
    • Fixed warning message log typo when
      emoveBody\ command does not complete.
  4. Tests:
    • Added SDF load + body removal verification in \ est/SharedMemory/test.c.

Verification

Verified with CMake build and unit tests passing (\Test_PhysicsClientServer).

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.

removeBody leaves rigid-body constraints pointing at the deleted body

1 participant