Merge pull request #2404 from erwincoumans/master
fix issues in previous softbody commits (always check for m_multibodyWorld == 0 before using the pointer in ::render method)
This commit is contained in:
@@ -1529,19 +1529,45 @@ const SharedMemoryStatus* PhysicsClientSharedMemory::processServerStatus()
|
|||||||
{
|
{
|
||||||
B3_PROFILE("CMD_LOADING_COMPLETED");
|
B3_PROFILE("CMD_LOADING_COMPLETED");
|
||||||
int numConstraints = serverCmd.m_sdfLoadedArgs.m_numUserConstraints;
|
int numConstraints = serverCmd.m_sdfLoadedArgs.m_numUserConstraints;
|
||||||
for (int i = 0; i < numConstraints; i++)
|
|
||||||
{
|
|
||||||
int constraintUid = serverCmd.m_sdfLoadedArgs.m_userConstraintUniqueIds[i];
|
|
||||||
m_data->m_constraintIdsRequestInfo.push_back(constraintUid);
|
|
||||||
}
|
|
||||||
int numBodies = serverCmd.m_sdfLoadedArgs.m_numBodies;
|
int numBodies = serverCmd.m_sdfLoadedArgs.m_numBodies;
|
||||||
|
if (serverCmd.m_type == CMD_SYNC_BODY_INFO_COMPLETED)
|
||||||
|
{
|
||||||
|
int* ids = (int*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
||||||
|
int* constraintUids = ids + numBodies;
|
||||||
|
for (int i = 0; i < numConstraints; i++)
|
||||||
|
{
|
||||||
|
int constraintUid = constraintUids[i];
|
||||||
|
m_data->m_constraintIdsRequestInfo.push_back(constraintUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < numConstraints; i++)
|
||||||
|
{
|
||||||
|
int constraintUid = serverCmd.m_sdfLoadedArgs.m_userConstraintUniqueIds[i];
|
||||||
|
m_data->m_constraintIdsRequestInfo.push_back(constraintUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (numBodies > 0)
|
if (numBodies > 0)
|
||||||
{
|
{
|
||||||
m_data->m_tempBackupServerStatus = m_data->m_lastServerStatus;
|
m_data->m_tempBackupServerStatus = m_data->m_lastServerStatus;
|
||||||
|
|
||||||
for (int i = 0; i < numBodies; i++)
|
if (serverCmd.m_type == CMD_SYNC_BODY_INFO_COMPLETED)
|
||||||
{
|
{
|
||||||
m_data->m_bodyIdsRequestInfo.push_back(serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i]);
|
int* bodyIds = (int*)m_data->m_testBlock1->m_bulletStreamDataServerToClientRefactor;
|
||||||
|
|
||||||
|
for (int i = 0; i < numBodies; i++)
|
||||||
|
{
|
||||||
|
m_data->m_bodyIdsRequestInfo.push_back(bodyIds[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < numBodies; i++)
|
||||||
|
{
|
||||||
|
m_data->m_bodyIdsRequestInfo.push_back(serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int bodyId = m_data->m_bodyIdsRequestInfo[m_data->m_bodyIdsRequestInfo.size() - 1];
|
int bodyId = m_data->m_bodyIdsRequestInfo[m_data->m_bodyIdsRequestInfo.size() - 1];
|
||||||
|
|||||||
@@ -688,7 +688,10 @@ void PhysicsDirect::processBodyJointInfo(int bodyUniqueId, const SharedMemorySta
|
|||||||
{
|
{
|
||||||
bf.setFileDNAisMemoryDNA();
|
bf.setFileDNAisMemoryDNA();
|
||||||
}
|
}
|
||||||
bf.parse(false);
|
{
|
||||||
|
BT_PROFILE("bf.parse");
|
||||||
|
bf.parse(false);
|
||||||
|
}
|
||||||
|
|
||||||
BodyJointInfoCache2* bodyJoints = new BodyJointInfoCache2;
|
BodyJointInfoCache2* bodyJoints = new BodyJointInfoCache2;
|
||||||
m_data->m_bodyJointMap.insert(bodyUniqueId, bodyJoints);
|
m_data->m_bodyJointMap.insert(bodyUniqueId, bodyJoints);
|
||||||
@@ -718,7 +721,8 @@ void PhysicsDirect::processBodyJointInfo(int bodyUniqueId, const SharedMemorySta
|
|||||||
bodyJoints->m_baseName = mb->m_baseName;
|
bodyJoints->m_baseName = mb->m_baseName;
|
||||||
}
|
}
|
||||||
addJointInfoFromMultiBodyData(mb, bodyJoints, m_data->m_verboseOutput);
|
addJointInfoFromMultiBodyData(mb, bodyJoints, m_data->m_verboseOutput);
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (bf.ok())
|
if (bf.ok())
|
||||||
{
|
{
|
||||||
@@ -919,17 +923,57 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CMD_SYNC_BODY_INFO_COMPLETED:
|
case CMD_SYNC_BODY_INFO_COMPLETED:
|
||||||
clearCachedBodies();
|
|
||||||
case CMD_MJCF_LOADING_COMPLETED:
|
case CMD_MJCF_LOADING_COMPLETED:
|
||||||
case CMD_SDF_LOADING_COMPLETED:
|
case CMD_SDF_LOADING_COMPLETED:
|
||||||
{
|
{
|
||||||
//we'll stream further info from the physics server
|
//we'll stream further info from the physics server
|
||||||
//so serverCmd will be invalid, make a copy
|
//so serverCmd will be invalid, make a copy
|
||||||
|
|
||||||
|
btAlignedObjectArray<int> bodyIdArray;
|
||||||
|
btAlignedObjectArray<int> constraintIdArray;
|
||||||
|
|
||||||
int numConstraints = serverCmd.m_sdfLoadedArgs.m_numUserConstraints;
|
int numConstraints = serverCmd.m_sdfLoadedArgs.m_numUserConstraints;
|
||||||
|
int numBodies = serverCmd.m_sdfLoadedArgs.m_numBodies;
|
||||||
|
|
||||||
|
bodyIdArray.reserve(numBodies);
|
||||||
|
constraintIdArray.reserve(numConstraints);
|
||||||
|
|
||||||
|
if (serverCmd.m_type == CMD_SYNC_BODY_INFO_COMPLETED)
|
||||||
|
{
|
||||||
|
clearCachedBodies();
|
||||||
|
const int* bodyIds = (int*)m_data->m_bulletStreamDataServerToClient;
|
||||||
|
const int* constaintIds = bodyIds + numBodies;
|
||||||
|
|
||||||
|
for (int i = 0; i < numConstraints; i++)
|
||||||
|
{
|
||||||
|
int constraintUid = constaintIds[i];
|
||||||
|
constraintIdArray.push_back(constraintUid);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < numBodies; i++)
|
||||||
|
{
|
||||||
|
int bodyUid = bodyIds[i];
|
||||||
|
bodyIdArray.push_back(bodyUid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < numConstraints; i++)
|
||||||
|
{
|
||||||
|
int constraintUid = serverCmd.m_sdfLoadedArgs.m_userConstraintUniqueIds[i];
|
||||||
|
constraintIdArray.push_back(constraintUid);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < numBodies; i++)
|
||||||
|
{
|
||||||
|
int bodyUid = serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i];
|
||||||
|
bodyIdArray.push_back(bodyUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < numConstraints; i++)
|
for (int i = 0; i < numConstraints; i++)
|
||||||
{
|
{
|
||||||
int constraintUid = serverCmd.m_sdfLoadedArgs.m_userConstraintUniqueIds[i];
|
int constraintUid = constraintIdArray[i];
|
||||||
|
|
||||||
m_data->m_tmpInfoRequestCommand.m_type = CMD_USER_CONSTRAINT;
|
m_data->m_tmpInfoRequestCommand.m_type = CMD_USER_CONSTRAINT;
|
||||||
m_data->m_tmpInfoRequestCommand.m_updateFlags = USER_CONSTRAINT_REQUEST_INFO;
|
m_data->m_tmpInfoRequestCommand.m_updateFlags = USER_CONSTRAINT_REQUEST_INFO;
|
||||||
@@ -953,10 +997,10 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int numBodies = serverCmd.m_sdfLoadedArgs.m_numBodies;
|
|
||||||
for (int i = 0; i < numBodies; i++)
|
for (int i = 0; i < numBodies; i++)
|
||||||
{
|
{
|
||||||
int bodyUniqueId = serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i];
|
int bodyUniqueId = bodyIdArray[i];
|
||||||
|
|
||||||
m_data->m_tmpInfoRequestCommand.m_type = CMD_REQUEST_BODY_INFO;
|
m_data->m_tmpInfoRequestCommand.m_type = CMD_REQUEST_BODY_INFO;
|
||||||
m_data->m_tmpInfoRequestCommand.m_sdfRequestInfoArgs.m_bodyUniqueId = bodyUniqueId;
|
m_data->m_tmpInfoRequestCommand.m_sdfRequestInfoArgs.m_bodyUniqueId = bodyUniqueId;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -654,16 +654,21 @@ public:
|
|||||||
{
|
{
|
||||||
if (m_debugDraw)
|
if (m_debugDraw)
|
||||||
{
|
{
|
||||||
|
m_csGUI->lock();
|
||||||
|
//draw stuff and flush?
|
||||||
m_debugDraw->drawDebugDrawerLines();
|
m_debugDraw->drawDebugDrawerLines();
|
||||||
|
m_csGUI->unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void clearLines()
|
virtual void clearLines()
|
||||||
{
|
{
|
||||||
if (m_debugDraw)
|
m_csGUI->lock();
|
||||||
{
|
if (m_debugDraw)
|
||||||
m_debugDraw->clearLines();
|
{
|
||||||
|
m_debugDraw->clearLines();
|
||||||
|
}
|
||||||
|
m_csGUI->unlock();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GUIHelperInterface* m_childGuiHelper;
|
GUIHelperInterface* m_childGuiHelper;
|
||||||
|
|
||||||
|
|||||||
@@ -9024,8 +9024,21 @@ static PyObject* pybullet_createMultiBody(PyObject* self, PyObject* args, PyObje
|
|||||||
if (statusType == CMD_CREATE_MULTI_BODY_COMPLETED)
|
if (statusType == CMD_CREATE_MULTI_BODY_COMPLETED)
|
||||||
{
|
{
|
||||||
int uid = b3GetStatusBodyIndex(statusHandle);
|
int uid = b3GetStatusBodyIndex(statusHandle);
|
||||||
PyObject* ob = PyLong_FromLong(uid);
|
if (numBatchPositions > 0)
|
||||||
return ob;
|
{
|
||||||
|
PyObject* pyResultList = PyTuple_New(numBatchPositions );
|
||||||
|
for (i = 0; i < numBatchPositions; i++)
|
||||||
|
{
|
||||||
|
PyTuple_SetItem(pyResultList, i, PyLong_FromLong(uid - numBatchPositions + i + 1));
|
||||||
|
}
|
||||||
|
return pyResultList;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PyObject* ob = PyLong_FromLong(uid);
|
||||||
|
return ob;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user