more work towards removeBody for C-API/pybullet, work-in-progress.
This commit is contained in:
@@ -724,6 +724,20 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
||||
m_data->m_userConstraintInfoMap.remove(cid);
|
||||
break;
|
||||
}
|
||||
case CMD_REMOVE_BODY_FAILED:
|
||||
{
|
||||
b3Warning("Remove body failed\n");
|
||||
break;
|
||||
}
|
||||
case CMD_REMOVE_BODY_COMPLETED:
|
||||
{
|
||||
for (int i=0;i<serverCmd.m_removeObjectArgs.m_numBodies;i++)
|
||||
{
|
||||
int bodyUniqueId = serverCmd.m_removeObjectArgs.m_bodyUniqueIds[i];
|
||||
removeCachedBody(bodyUniqueId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_CHANGE_USER_CONSTRAINT_COMPLETED:
|
||||
{
|
||||
int cid = serverCmd.m_userConstraintResultArgs.m_userConstraintUniqueId;
|
||||
@@ -909,6 +923,28 @@ int PhysicsDirect::getNumBodies() const
|
||||
return m_data->m_bodyJointMap.size();
|
||||
}
|
||||
|
||||
void PhysicsDirect::removeCachedBody(int bodyUniqueId)
|
||||
{
|
||||
BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap[bodyUniqueId];
|
||||
if (bodyJointsPtr && *bodyJointsPtr)
|
||||
{
|
||||
BodyJointInfoCache2* bodyJoints = *bodyJointsPtr;
|
||||
for (int j=0;j<bodyJoints->m_jointInfo.size();j++) {
|
||||
if (bodyJoints->m_jointInfo[j].m_jointName)
|
||||
{
|
||||
free(bodyJoints->m_jointInfo[j].m_jointName);
|
||||
}
|
||||
if (bodyJoints->m_jointInfo[j].m_linkName)
|
||||
{
|
||||
free(bodyJoints->m_jointInfo[j].m_linkName);
|
||||
}
|
||||
}
|
||||
delete (*bodyJointsPtr);
|
||||
m_data->m_bodyJointMap.remove(bodyUniqueId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int PhysicsDirect::getNumUserConstraints() const
|
||||
{
|
||||
return m_data->m_userConstraintInfoMap.size();
|
||||
|
||||
Reference in New Issue
Block a user