Changes tickPlugins to reportNotifications and only calls the processNotifications function on the plugins when there are actually notifications available. tickPlugins will to into a separate PR.
This commit is contained in:
@@ -44,7 +44,7 @@ public:
|
|||||||
virtual void enableRealTimeSimulation(bool enableRealTimeSim)=0;
|
virtual void enableRealTimeSimulation(bool enableRealTimeSim)=0;
|
||||||
virtual bool isRealTimeSimulationEnabled() const=0;
|
virtual bool isRealTimeSimulationEnabled() const=0;
|
||||||
|
|
||||||
virtual void tickPlugins() = 0;
|
virtual void reportNotifications() = 0;
|
||||||
|
|
||||||
virtual void enableCommandLogging(bool enable, const char* fileName)=0;
|
virtual void enableCommandLogging(bool enable, const char* fileName)=0;
|
||||||
virtual void replayFromLogFile(const char* fileName)=0;
|
virtual void replayFromLogFile(const char* fileName)=0;
|
||||||
|
|||||||
@@ -1218,7 +1218,7 @@ bool PhysicsDirect::submitClientCommand(const struct SharedMemoryCommand& comman
|
|||||||
if (m_data->m_ownsCommandProcessor)
|
if (m_data->m_ownsCommandProcessor)
|
||||||
{
|
{
|
||||||
CommandProcessorInterface *commandProcessor = (CommandProcessorInterface *)m_data->m_commandProcessor;
|
CommandProcessorInterface *commandProcessor = (CommandProcessorInterface *)m_data->m_commandProcessor;
|
||||||
commandProcessor->tickPlugins();
|
commandProcessor->reportNotifications();
|
||||||
}
|
}
|
||||||
/*if (hasStatus)
|
/*if (hasStatus)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1902,8 +1902,8 @@ void PhysicsServerCommandProcessor::processCollisionForces(btScalar timeStep)
|
|||||||
#endif//B3_ENABLE_TINY_AUDIO
|
#endif//B3_ENABLE_TINY_AUDIO
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsServerCommandProcessor::tickPlugins() {
|
void PhysicsServerCommandProcessor::reportNotifications() {
|
||||||
m_data->m_pluginManager.tickPlugins();
|
m_data->m_pluginManager.reportNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsServerCommandProcessor::tickPlugins(btScalar timeStep, bool isPreTick)
|
void PhysicsServerCommandProcessor::tickPlugins(btScalar timeStep, bool isPreTick)
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public:
|
|||||||
virtual void replayLogCommand(char* bufferServerToClient, int bufferSizeInBytes );
|
virtual void replayLogCommand(char* bufferServerToClient, int bufferSizeInBytes );
|
||||||
|
|
||||||
//logging of object states (position etc)
|
//logging of object states (position etc)
|
||||||
virtual void tickPlugins();
|
virtual void reportNotifications();
|
||||||
void tickPlugins(btScalar timeStep, bool isPreTick);
|
void tickPlugins(btScalar timeStep, bool isPreTick);
|
||||||
void logObjectStates(btScalar timeStep);
|
void logObjectStates(btScalar timeStep);
|
||||||
void processCollisionForces(btScalar timeStep);
|
void processCollisionForces(btScalar timeStep);
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ void MotionThreadFunc(void* userPtr,void* lsMemory)
|
|||||||
numCmdSinceSleep1ms++;
|
numCmdSinceSleep1ms++;
|
||||||
}
|
}
|
||||||
|
|
||||||
args->m_physicsServerPtr->tickPlugins();
|
args->m_physicsServerPtr->reportNotifications();
|
||||||
|
|
||||||
args->m_cs->lock();
|
args->m_cs->lock();
|
||||||
cachedSharedParam = args->m_cs->getSharedParam(0);
|
cachedSharedParam = args->m_cs->getSharedParam(0);
|
||||||
|
|||||||
@@ -242,9 +242,9 @@ bool PhysicsServerSharedMemory::isRealTimeSimulationEnabled() const
|
|||||||
return m_data->m_commandProcessor->isRealTimeSimulationEnabled();
|
return m_data->m_commandProcessor->isRealTimeSimulationEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsServerSharedMemory::tickPlugins()
|
void PhysicsServerSharedMemory::reportNotifications()
|
||||||
{
|
{
|
||||||
m_data->m_commandProcessor->tickPlugins();
|
m_data->m_commandProcessor->reportNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsServerSharedMemory::processClientCommands()
|
void PhysicsServerSharedMemory::processClientCommands()
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
virtual void enableRealTimeSimulation(bool enableRealTimeSim);
|
virtual void enableRealTimeSimulation(bool enableRealTimeSim);
|
||||||
virtual bool isRealTimeSimulationEnabled() const;
|
virtual bool isRealTimeSimulationEnabled() const;
|
||||||
|
|
||||||
virtual void tickPlugins();
|
virtual void reportNotifications();
|
||||||
|
|
||||||
//bool supportsJointMotor(class btMultiBody* body, int linkIndex);
|
//bool supportsJointMotor(class btMultiBody* body, int linkIndex);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct b3Plugin
|
|||||||
|
|
||||||
PFN_TICK m_preTickFunc;
|
PFN_TICK m_preTickFunc;
|
||||||
PFN_TICK m_postTickFunc;
|
PFN_TICK m_postTickFunc;
|
||||||
PFN_TICK m_tickPluginFunc;
|
PFN_TICK m_processNotificationsFunc;
|
||||||
|
|
||||||
PFN_GET_RENDER_INTERFACE m_getRendererFunc;
|
PFN_GET_RENDER_INTERFACE m_getRendererFunc;
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ struct b3Plugin
|
|||||||
m_executeCommandFunc(0),
|
m_executeCommandFunc(0),
|
||||||
m_preTickFunc(0),
|
m_preTickFunc(0),
|
||||||
m_postTickFunc(0),
|
m_postTickFunc(0),
|
||||||
m_tickPluginFunc(0),
|
m_processNotificationsFunc(0),
|
||||||
m_getRendererFunc(0),
|
m_getRendererFunc(0),
|
||||||
m_userPointer(0)
|
m_userPointer(0)
|
||||||
{
|
{
|
||||||
@@ -90,7 +90,7 @@ struct b3PluginManagerInternalData
|
|||||||
int m_activeRendererPluginUid;
|
int m_activeRendererPluginUid;
|
||||||
|
|
||||||
b3PluginManagerInternalData()
|
b3PluginManagerInternalData()
|
||||||
:m_activeRendererPluginUid(-1), m_activeNotificationsBufferIndex(0)
|
:m_activeNotificationsBufferIndex(0), m_activeRendererPluginUid(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -174,15 +174,15 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
|||||||
std::string executePluginCommandStr = std::string("executePluginCommand") + postFix;
|
std::string executePluginCommandStr = std::string("executePluginCommand") + postFix;
|
||||||
std::string preTickPluginCallbackStr = std::string("preTickPluginCallback") + postFix;
|
std::string preTickPluginCallbackStr = std::string("preTickPluginCallback") + postFix;
|
||||||
std::string postTickPluginCallback = std::string("postTickPluginCallback") + postFix;
|
std::string postTickPluginCallback = std::string("postTickPluginCallback") + postFix;
|
||||||
std::string tickPluginStr = std::string("tickPlugin") + postFix;
|
std::string processNotificationsStr = std::string("processNotifications") + postFix;
|
||||||
std::string getRendererStr = std::string("getRenderInterface") + postFix;
|
std::string getRendererStr = std::string("getRenderInterface") + postFix;
|
||||||
|
|
||||||
plugin->m_initFunc = (PFN_INIT)B3_DYNLIB_IMPORT(pluginHandle, initStr.c_str());
|
plugin->m_initFunc = (PFN_INIT)B3_DYNLIB_IMPORT(pluginHandle, initStr.c_str());
|
||||||
plugin->m_exitFunc = (PFN_EXIT)B3_DYNLIB_IMPORT(pluginHandle, exitStr.c_str());
|
plugin->m_exitFunc = (PFN_EXIT)B3_DYNLIB_IMPORT(pluginHandle, exitStr.c_str());
|
||||||
plugin->m_executeCommandFunc = (PFN_EXECUTE)B3_DYNLIB_IMPORT(pluginHandle, executePluginCommandStr.c_str());
|
plugin->m_executeCommandFunc = (PFN_EXECUTE)B3_DYNLIB_IMPORT(pluginHandle, executePluginCommandStr.c_str());
|
||||||
plugin->m_preTickFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, preTickPluginCallbackStr.c_str());
|
plugin->m_preTickFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, preTickPluginCallbackStr.c_str());
|
||||||
plugin->m_postTickFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, postTickPluginCallback.c_str());
|
plugin->m_postTickFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, postTickPluginCallback.c_str());
|
||||||
plugin->m_tickPluginFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, tickPluginStr.c_str());
|
plugin->m_processNotificationsFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, processNotificationsStr.c_str());
|
||||||
plugin->m_getRendererFunc = (PFN_GET_RENDER_INTERFACE)B3_DYNLIB_IMPORT(pluginHandle, getRendererStr.c_str());
|
plugin->m_getRendererFunc = (PFN_GET_RENDER_INTERFACE)B3_DYNLIB_IMPORT(pluginHandle, getRendererStr.c_str());
|
||||||
|
|
||||||
if (plugin->m_initFunc && plugin->m_exitFunc && plugin->m_executeCommandFunc)
|
if (plugin->m_initFunc && plugin->m_exitFunc && plugin->m_executeCommandFunc)
|
||||||
@@ -292,9 +292,14 @@ void b3PluginManager::tickPlugins(double timeStep, bool isPreTick)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void b3PluginManager::tickPlugins()
|
void b3PluginManager::reportNotifications()
|
||||||
{
|
{
|
||||||
b3AlignedObjectArray<b3Notification> ¬ifications = m_data->m_notifications[m_data->m_activeNotificationsBufferIndex];
|
b3AlignedObjectArray<b3Notification> ¬ifications = m_data->m_notifications[m_data->m_activeNotificationsBufferIndex];
|
||||||
|
if (notifications.size() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Swap notification buffers.
|
// Swap notification buffers.
|
||||||
m_data->m_activeNotificationsBufferIndex = 1 - m_data->m_activeNotificationsBufferIndex;
|
m_data->m_activeNotificationsBufferIndex = 1 - m_data->m_activeNotificationsBufferIndex;
|
||||||
|
|
||||||
@@ -313,13 +318,13 @@ void b3PluginManager::tickPlugins()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin->m_tickPluginFunc) {
|
if (plugin->m_processNotificationsFunc) {
|
||||||
b3PluginContext context = {0};
|
b3PluginContext context = {0};
|
||||||
context.m_userPointer = plugin->m_userPointer;
|
context.m_userPointer = plugin->m_userPointer;
|
||||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||||
context.m_numNotifications = notifications.size();
|
context.m_numNotifications = notifications.size();
|
||||||
context.m_notifications = notifications.size() ? ¬ifications[0] : 0;
|
context.m_notifications = notifications.size() ? ¬ifications[0] : 0;
|
||||||
plugin->m_tickPluginFunc(&context);
|
plugin->m_processNotificationsFunc(&context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifications.clear();
|
notifications.clear();
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ class b3PluginManager
|
|||||||
void clearEvents();
|
void clearEvents();
|
||||||
|
|
||||||
void addNotification(const struct b3Notification& notification);
|
void addNotification(const struct b3Notification& notification);
|
||||||
|
void reportNotifications();
|
||||||
|
|
||||||
void tickPlugins(double timeStep, bool isPreTick);
|
void tickPlugins(double timeStep, bool isPreTick);
|
||||||
void tickPlugins();
|
|
||||||
|
|
||||||
int registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT initFunc,PFN_EXIT exitFunc, PFN_EXECUTE executeCommandFunc, PFN_TICK preTickFunc, PFN_TICK postTickFunc, PFN_GET_RENDER_INTERFACE getRendererFunc);
|
int registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT initFunc,PFN_EXIT exitFunc, PFN_EXECUTE executeCommandFunc, PFN_TICK preTickFunc, PFN_TICK postTickFunc, PFN_GET_RENDER_INTERFACE getRendererFunc);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user