mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-09-21 17:54:29 +00:00
Add an option for a plugin to report return data after calling executePluginCommand. Also add python binding.
Currently the return data has to fit in shared memory, 8MB (Linux, Windows) or 1MB (Apple) Preparation for streaming is added (to allow unlimited return data, see CMD_CUSTOM_COMMAND_STREAM_RETURN_DATA) New C-API: b3GetStatusPluginCommandReturnData PyBullet reports return data if available, in pybullet_executePluginCommand For the plugin developer: plugin can provide additional return data for executePluginCommand in the b3PluginContext, during executePluginCommand. Lifetime of this m_returnData pointer is minimum of next call to the next executePluginCommand or plugin termination.
This commit is contained in:
@@ -79,6 +79,10 @@ struct PhysicsDirectInternalData
|
||||
btHashMap<btHashInt, SharedMemoryUserData> m_userDataMap;
|
||||
btHashMap<SharedMemoryUserDataHashKey, int> m_userDataHandleLookup;
|
||||
|
||||
btAlignedObjectArray<char> m_cachedReturnData;
|
||||
b3UserDataValue m_cachedReturnDataValue;
|
||||
|
||||
|
||||
PhysicsCommandProcessorInterface* m_commandProcessor;
|
||||
bool m_ownsCommandProcessor;
|
||||
double m_timeOutInSeconds;
|
||||
@@ -1113,10 +1117,7 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
||||
b3Warning("Request mesh data failed");
|
||||
break;
|
||||
}
|
||||
case CMD_CUSTOM_COMMAND_COMPLETED:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case CMD_CUSTOM_COMMAND_FAILED:
|
||||
{
|
||||
b3Warning("custom plugin command failed");
|
||||
@@ -1309,10 +1310,27 @@ void PhysicsDirect::postProcessStatus(const struct SharedMemoryStatus& serverCmd
|
||||
{
|
||||
break;
|
||||
}
|
||||
case CMD_CUSTOM_COMMAND_COMPLETED:
|
||||
{
|
||||
m_data->m_cachedReturnData.resize(serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes);
|
||||
m_data->m_cachedReturnDataValue.m_length = serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes;
|
||||
|
||||
if (serverCmd.m_customCommandResultArgs.m_returnDataSizeInBytes)
|
||||
{
|
||||
m_data->m_cachedReturnDataValue.m_type = serverCmd.m_customCommandResultArgs.m_returnDataType;
|
||||
m_data->m_cachedReturnDataValue.m_data1 = &m_data->m_cachedReturnData[0];
|
||||
for (int i = 0; i < serverCmd.m_numDataStreamBytes; i++)
|
||||
{
|
||||
m_data->m_cachedReturnData[i] = m_data->m_bulletStreamDataServerToClient[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
//b3Warning("Unknown server status type");
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
bool PhysicsDirect::submitClientCommand(const struct SharedMemoryCommand& command)
|
||||
@@ -1651,6 +1669,16 @@ void PhysicsDirect::getCachedMassMatrix(int dofCountCheck, double* massMatrix)
|
||||
}
|
||||
}
|
||||
|
||||
bool PhysicsDirect::getCachedReturnData(b3UserDataValue* returnData)
|
||||
{
|
||||
if (m_data->m_cachedReturnDataValue.m_length)
|
||||
{
|
||||
*returnData = m_data->m_cachedReturnDataValue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PhysicsDirect::setTimeOut(double timeOutInSeconds)
|
||||
{
|
||||
m_data->m_timeOutInSeconds = timeOutInSeconds;
|
||||
|
||||
Reference in New Issue
Block a user