mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-06-08 08:13:55 +00:00
Support getCachedReturnData for PhysicsLoopBack
re-use existing code path for streaming plugin return data (work-in-progress)
This commit is contained in:
@@ -3069,7 +3069,7 @@ B3_SHARED_API void b3CustomCommandExecutePluginCommand(b3SharedMemoryCommandHand
|
||||
{
|
||||
command->m_updateFlags |= CMD_CUSTOM_COMMAND_EXECUTE_PLUGIN_COMMAND;
|
||||
command->m_customCommandArgs.m_pluginUniqueId = pluginUniqueId;
|
||||
|
||||
command->m_customCommandArgs.m_startingReturnBytes = 0;
|
||||
command->m_customCommandArgs.m_arguments.m_numInts = 0;
|
||||
command->m_customCommandArgs.m_arguments.m_numFloats = 0;
|
||||
command->m_customCommandArgs.m_arguments.m_text[0] = 0;
|
||||
|
||||
@@ -227,6 +227,10 @@ void PhysicsLoopBack::getCachedMassMatrix(int dofCountCheck, double* massMatrix)
|
||||
{
|
||||
m_data->m_physicsClient->getCachedMassMatrix(dofCountCheck, massMatrix);
|
||||
}
|
||||
bool PhysicsLoopBack::getCachedReturnData(struct b3UserDataValue* returnData)
|
||||
{
|
||||
return m_data->m_physicsClient->getCachedReturnData(returnData);
|
||||
}
|
||||
|
||||
void PhysicsLoopBack::setTimeOut(double timeOutInSeconds)
|
||||
{
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
|
||||
virtual void getCachedMassMatrix(int dofCountCheck, double* massMatrix);
|
||||
|
||||
virtual bool getCachedReturnData(struct b3UserDataValue* returnData);
|
||||
|
||||
virtual void setTimeOut(double timeOutInSeconds);
|
||||
virtual double getTimeOut() const;
|
||||
|
||||
|
||||
@@ -5759,6 +5759,8 @@ bool PhysicsServerCommandProcessor::processCustomCommand(const struct SharedMemo
|
||||
serverCmd.m_type = CMD_CUSTOM_COMMAND_FAILED;
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes = 0;
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataType = -1;
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataStart = 0;
|
||||
|
||||
serverCmd.m_customCommandResultArgs.m_pluginUniqueId = -1;
|
||||
|
||||
if (clientCmd.m_updateFlags & CMD_CUSTOM_COMMAND_LOAD_PLUGIN)
|
||||
@@ -5783,36 +5785,20 @@ bool PhysicsServerCommandProcessor::processCustomCommand(const struct SharedMemo
|
||||
m_data->m_pluginManager.unloadPlugin(clientCmd.m_customCommandArgs.m_pluginUniqueId);
|
||||
serverCmd.m_type = CMD_CUSTOM_COMMAND_COMPLETED;
|
||||
}
|
||||
if (clientCmd.m_updateFlags & CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA)
|
||||
{
|
||||
serverCmd.m_type = CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA_FAILED;
|
||||
const b3UserDataValue* returnData = m_data->m_pluginManager.getReturnData(clientCmd.m_customCommandArgs.m_pluginUniqueId);
|
||||
if (returnData)
|
||||
{
|
||||
int startBytes = clientCmd.m_customCommandArgs.m_startingReturnBytes;
|
||||
if (startBytes >= 0 && startBytes < returnData->m_length)
|
||||
{
|
||||
int totalRemain = returnData->m_length - startBytes;
|
||||
int numBytes = totalRemain <= bufferSizeInBytes ? totalRemain : bufferSizeInBytes;
|
||||
serverStatusOut.m_numDataStreamBytes = numBytes;
|
||||
for (int i = 0; i < numBytes; i++)
|
||||
{
|
||||
bufferServerToClient[i] = returnData->m_data1[i + startBytes];
|
||||
}
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes = returnData->m_length;
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataType = returnData->m_type;
|
||||
serverCmd.m_type = CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA_COMPLETED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (clientCmd.m_updateFlags & CMD_CUSTOM_COMMAND_EXECUTE_PLUGIN_COMMAND)
|
||||
{
|
||||
int result = m_data->m_pluginManager.executePluginCommand(clientCmd.m_customCommandArgs.m_pluginUniqueId, &clientCmd.m_customCommandArgs.m_arguments);
|
||||
serverCmd.m_customCommandResultArgs.m_executeCommandResult = result;
|
||||
int startBytes = clientCmd.m_customCommandArgs.m_startingReturnBytes;
|
||||
if (startBytes == 0)
|
||||
{
|
||||
int result = m_data->m_pluginManager.executePluginCommand(clientCmd.m_customCommandArgs.m_pluginUniqueId, &clientCmd.m_customCommandArgs.m_arguments);
|
||||
serverCmd.m_customCommandResultArgs.m_executeCommandResult = result;
|
||||
}
|
||||
const b3UserDataValue* returnData = m_data->m_pluginManager.getReturnData(clientCmd.m_customCommandArgs.m_pluginUniqueId);
|
||||
if (returnData)
|
||||
{
|
||||
int numBytes = returnData->m_length <= bufferSizeInBytes ? returnData->m_length : bufferSizeInBytes;
|
||||
int totalRemain = returnData->m_length - startBytes;
|
||||
int numBytes = totalRemain <= bufferSizeInBytes ? totalRemain : bufferSizeInBytes;
|
||||
serverStatusOut.m_numDataStreamBytes = numBytes;
|
||||
for (int i = 0; i < numBytes; i++)
|
||||
{
|
||||
@@ -5820,6 +5806,7 @@ bool PhysicsServerCommandProcessor::processCustomCommand(const struct SharedMemo
|
||||
}
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes = returnData->m_length;
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataType = returnData->m_type;
|
||||
serverCmd.m_customCommandResultArgs.m_returnDataStart = startBytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -124,7 +124,6 @@ enum CustomCommandEnum
|
||||
CMD_CUSTOM_COMMAND_UNLOAD_PLUGIN = 2,
|
||||
CMD_CUSTOM_COMMAND_EXECUTE_PLUGIN_COMMAND = 4,
|
||||
CMD_CUSTOM_COMMAND_LOAD_PLUGIN_POSTFIX = 8,
|
||||
CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA = 16,
|
||||
};
|
||||
|
||||
struct b3CustomCommand
|
||||
@@ -142,6 +141,7 @@ struct b3CustomCommandResultArgs
|
||||
int m_executeCommandResult;
|
||||
int m_returnDataType;
|
||||
int m_returnDataSizeInBytes;
|
||||
int m_returnDataStart;
|
||||
};
|
||||
|
||||
struct BulletDataStreamArgs
|
||||
|
||||
@@ -239,8 +239,6 @@ enum EnumSharedMemoryServerStatus
|
||||
CMD_REQUEST_MESH_DATA_COMPLETED,
|
||||
CMD_REQUEST_MESH_DATA_FAILED,
|
||||
|
||||
CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA_COMPLETED,
|
||||
CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA_FAILED,
|
||||
//don't go beyond 'CMD_MAX_SERVER_COMMANDS!
|
||||
CMD_MAX_SERVER_COMMANDS
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user