Repository navigation
Fix pybullet saveWorld resurrecting removed bodies after body ID reuse (#4810) - #4816
Open
paneendrakumar0 wants to merge 1 commit into
Open
paneendrakumar0 wants to merge 1 commit into
paneendrakumar0 wants to merge 1 commit into
Conversation
bulletphysics#4810) When a body is removed via processRemoveBodyCommand, its body ID was freed in m_bodyHandles but remained in m_saveWorldBodyData. If a later body reused that body ID, saveWorld() resolved the stale record through the new body and serialized both assets at the new body's transform. This commit purges the removed bodyUniqueId from m_saveWorldBodyData upon body removal, and deletes empty SaveWorldObjectData entries. A regression unit test is added to TestPybulletMethods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4810.
Description
In
examples/SharedMemory/PhysicsServerCommandProcessor.cpp, PyBullet tracks loaded models inm_saveWorldBodyData. Previously, when a body was removed viaprocessRemoveBodyCommand(), its body ID was freed inm_bodyHandlesbut was never removed fromm_saveWorldBodyData.When a subsequent body load operation allocated and reused that newly freed body ID,
saveWorld()resolved the stale record through the newly created body handle and serialized both assets at the new body's transform, causing deleted bodies to be resurrected in saved Python worlds.Solution
PhysicsServerCommandProcessor::processRemoveBodyCommand(), locate and remove itsbodyUniqueIdfromm_saveWorldBodyData.SaveWorldObjectDataentry has no remaining bodies, remove the entry fromm_saveWorldBodyData.test_save_world_removed_body_reusetoTestPybulletMethodsinexamples/pybullet/unittests/unittests.py.