reduce stack usage

This commit is contained in:
erwincoumans
2017-11-22 15:30:56 -08:00
parent ab843b26f0
commit 76772fd301

View File

@@ -29,6 +29,9 @@ struct PhysicsDirectInternalData
btAlignedObjectArray<char> m_serverDNA; btAlignedObjectArray<char> m_serverDNA;
SharedMemoryCommand m_command; SharedMemoryCommand m_command;
SharedMemoryStatus m_serverStatus; SharedMemoryStatus m_serverStatus;
SharedMemoryCommand m_tmpInfoRequestCommand;
SharedMemoryStatus m_tmpInfoStatus;
bool m_hasStatus; bool m_hasStatus;
bool m_verboseOutput; bool m_verboseOutput;
@@ -79,6 +82,9 @@ struct PhysicsDirectInternalData
PhysicsDirect::PhysicsDirect(PhysicsCommandProcessorInterface* physSdk, bool passSdkOwnership) PhysicsDirect::PhysicsDirect(PhysicsCommandProcessorInterface* physSdk, bool passSdkOwnership)
{ {
int sz = sizeof(SharedMemoryCommand);
int sz2 = sizeof(SharedMemoryStatus);
m_data = new PhysicsDirectInternalData; m_data = new PhysicsDirectInternalData;
m_data->m_commandProcessor = physSdk; m_data->m_commandProcessor = physSdk;
m_data->m_ownsCommandProcessor = passSdkOwnership; m_data->m_ownsCommandProcessor = passSdkOwnership;
@@ -814,12 +820,12 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
for (int i=0;i<numConstraints;i++) for (int i=0;i<numConstraints;i++)
{ {
int constraintUid = serverCmd.m_sdfLoadedArgs.m_userConstraintUniqueIds[i]; int constraintUid = serverCmd.m_sdfLoadedArgs.m_userConstraintUniqueIds[i];
SharedMemoryCommand infoRequestCommand;
infoRequestCommand.m_type = CMD_USER_CONSTRAINT; m_data->m_tmpInfoRequestCommand.m_type = CMD_USER_CONSTRAINT;
infoRequestCommand.m_updateFlags = USER_CONSTRAINT_REQUEST_INFO; m_data->m_tmpInfoRequestCommand.m_updateFlags = USER_CONSTRAINT_REQUEST_INFO;
infoRequestCommand.m_userConstraintArguments.m_userConstraintUniqueId = constraintUid; m_data->m_tmpInfoRequestCommand.m_userConstraintArguments.m_userConstraintUniqueId = constraintUid;
SharedMemoryStatus infoStatus;
bool hasStatus = m_data->m_commandProcessor->processCommand(infoRequestCommand, infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE); bool hasStatus = m_data->m_commandProcessor->processCommand(m_data->m_tmpInfoRequestCommand, m_data->m_tmpInfoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
b3Clock clock; b3Clock clock;
@@ -828,13 +834,13 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds)) while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
{ {
hasStatus = m_data->m_commandProcessor->receiveStatus(infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE); hasStatus = m_data->m_commandProcessor->receiveStatus(m_data->m_tmpInfoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
} }
if (hasStatus) if (hasStatus)
{ {
int cid = infoStatus.m_userConstraintResultArgs.m_userConstraintUniqueId; int cid = m_data->m_tmpInfoStatus.m_userConstraintResultArgs.m_userConstraintUniqueId;
m_data->m_userConstraintInfoMap.insert(cid,infoStatus.m_userConstraintResultArgs); m_data->m_userConstraintInfoMap.insert(cid,m_data->m_tmpInfoStatus.m_userConstraintResultArgs);
} }
} }
@@ -842,11 +848,11 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
for (int i = 0; i<numBodies; i++) for (int i = 0; i<numBodies; i++)
{ {
int bodyUniqueId = serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i]; int bodyUniqueId = serverCmd.m_sdfLoadedArgs.m_bodyUniqueIds[i];
SharedMemoryCommand infoRequestCommand;
infoRequestCommand.m_type = CMD_REQUEST_BODY_INFO; m_data->m_tmpInfoRequestCommand.m_type = CMD_REQUEST_BODY_INFO;
infoRequestCommand.m_sdfRequestInfoArgs.m_bodyUniqueId = bodyUniqueId; m_data->m_tmpInfoRequestCommand.m_sdfRequestInfoArgs.m_bodyUniqueId = bodyUniqueId;
SharedMemoryStatus infoStatus;
bool hasStatus = m_data->m_commandProcessor->processCommand(infoRequestCommand, infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE); bool hasStatus = m_data->m_commandProcessor->processCommand(m_data->m_tmpInfoRequestCommand, m_data->m_tmpInfoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
b3Clock clock; b3Clock clock;
@@ -855,12 +861,12 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds)) while ((!hasStatus) && (clock.getTimeInSeconds()-startTime < timeOutInSeconds))
{ {
hasStatus = m_data->m_commandProcessor->receiveStatus(infoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE); hasStatus = m_data->m_commandProcessor->receiveStatus(m_data->m_tmpInfoStatus, &m_data->m_bulletStreamDataServerToClient[0], SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE);
} }
if (hasStatus) if (hasStatus)
{ {
processBodyJointInfo(bodyUniqueId, infoStatus); processBodyJointInfo(bodyUniqueId, m_data->m_tmpInfoStatus);
} }
} }
break; break;