Merge pull request #2361 from RanTig/sync-cache-clear
Clears body and user data caches on syncBodyInfo and syncUserData
This commit is contained in:
@@ -282,11 +282,9 @@ void PhysicsClientSharedMemory::removeCachedBody(int bodyUniqueId)
|
||||
m_data->m_bodyJointMap.remove(bodyUniqueId);
|
||||
}
|
||||
}
|
||||
void PhysicsClientSharedMemory::resetData()
|
||||
|
||||
void PhysicsClientSharedMemory::clearCachedBodies()
|
||||
{
|
||||
m_data->m_debugLinesFrom.clear();
|
||||
m_data->m_debugLinesTo.clear();
|
||||
m_data->m_debugLinesColor.clear();
|
||||
for (int i = 0; i < m_data->m_bodyJointMap.size(); i++)
|
||||
{
|
||||
BodyJointInfoCache** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
|
||||
@@ -296,9 +294,17 @@ void PhysicsClientSharedMemory::resetData()
|
||||
}
|
||||
}
|
||||
m_data->m_bodyJointMap.clear();
|
||||
}
|
||||
|
||||
void PhysicsClientSharedMemory::resetData()
|
||||
{
|
||||
m_data->m_debugLinesFrom.clear();
|
||||
m_data->m_debugLinesTo.clear();
|
||||
m_data->m_debugLinesColor.clear();
|
||||
m_data->m_userConstraintInfoMap.clear();
|
||||
m_data->m_userDataHandleLookup.clear();
|
||||
m_data->m_userDataMap.clear();
|
||||
m_data->m_userDataHandleLookup.clear();
|
||||
clearCachedBodies();
|
||||
}
|
||||
void PhysicsClientSharedMemory::setSharedMemoryKey(int key)
|
||||
{
|
||||
@@ -1270,6 +1276,7 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus()
|
||||
|
||||
case CMD_SYNC_BODY_INFO_COMPLETED:
|
||||
{
|
||||
clearCachedBodies();
|
||||
break;
|
||||
}
|
||||
case CMD_STATE_LOGGING_START_COMPLETED:
|
||||
@@ -1560,9 +1567,9 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus()
|
||||
{
|
||||
(*bodyJointsPtr)->m_userDataIds.clear();
|
||||
}
|
||||
}
|
||||
m_data->m_userDataMap.clear();
|
||||
m_data->m_userDataHandleLookup.clear();
|
||||
}
|
||||
const int numIdentifiers = serverCmd.m_syncUserDataArgs.m_numUserDataIdentifiers;
|
||||
if (numIdentifiers > 0)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ protected:
|
||||
void processBodyJointInfo(int bodyUniqueId, const struct SharedMemoryStatus& serverCmd);
|
||||
void resetData();
|
||||
void removeCachedBody(int bodyUniqueId);
|
||||
void clearCachedBodies();
|
||||
virtual void renderSceneInternal(){};
|
||||
|
||||
public:
|
||||
|
||||
@@ -142,6 +142,14 @@ void PhysicsDirect::resetData()
|
||||
m_data->m_debugLinesFrom.clear();
|
||||
m_data->m_debugLinesTo.clear();
|
||||
m_data->m_debugLinesColor.clear();
|
||||
m_data->m_userConstraintInfoMap.clear();
|
||||
m_data->m_userDataMap.clear();
|
||||
m_data->m_userDataHandleLookup.clear();
|
||||
clearCachedBodies();
|
||||
}
|
||||
|
||||
void PhysicsDirect::clearCachedBodies()
|
||||
{
|
||||
for (int i = 0; i < m_data->m_bodyJointMap.size(); i++)
|
||||
{
|
||||
BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
|
||||
@@ -151,7 +159,6 @@ void PhysicsDirect::resetData()
|
||||
}
|
||||
}
|
||||
m_data->m_bodyJointMap.clear();
|
||||
m_data->m_userConstraintInfoMap.clear();
|
||||
}
|
||||
|
||||
// return true if connection succesfull, can also check 'isConnected'
|
||||
@@ -912,6 +919,7 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
||||
break;
|
||||
}
|
||||
case CMD_SYNC_BODY_INFO_COMPLETED:
|
||||
clearCachedBodies();
|
||||
case CMD_MJCF_LOADING_COMPLETED:
|
||||
case CMD_SDF_LOADING_COMPLETED:
|
||||
{
|
||||
@@ -1193,6 +1201,8 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
||||
{
|
||||
B3_PROFILE("CMD_SYNC_USER_DATA_COMPLETED");
|
||||
// Remove all cached user data entries.
|
||||
m_data->m_userDataMap.clear();
|
||||
m_data->m_userDataHandleLookup.clear();
|
||||
for (int i = 0; i < m_data->m_bodyJointMap.size(); i++)
|
||||
{
|
||||
BodyJointInfoCache2** bodyJointsPtr = m_data->m_bodyJointMap.getAtIndex(i);
|
||||
@@ -1200,8 +1210,6 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
||||
{
|
||||
(*bodyJointsPtr)->m_userDataIds.clear();
|
||||
}
|
||||
m_data->m_userDataMap.clear();
|
||||
m_data->m_userDataHandleLookup.clear();
|
||||
}
|
||||
const int numIdentifiers = serverCmd.m_syncUserDataArgs.m_numUserDataIdentifiers;
|
||||
int* identifiers = new int[numIdentifiers];
|
||||
|
||||
@@ -34,6 +34,8 @@ protected:
|
||||
|
||||
void removeCachedBody(int bodyUniqueId);
|
||||
|
||||
void clearCachedBodies();
|
||||
|
||||
public:
|
||||
PhysicsDirect(class PhysicsCommandProcessorInterface* physSdk, bool passSdkOwnership);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user