Merge pull request #1859 from erwincoumans/master

only add notifications if there is a plugin that needs them
This commit is contained in:
erwincoumans
2018-09-04 20:59:29 -07:00
committed by GitHub
3 changed files with 27 additions and 5 deletions

View File

@@ -92,9 +92,11 @@ struct b3PluginManagerInternalData
b3AlignedObjectArray<b3Notification> m_notifications[2]; b3AlignedObjectArray<b3Notification> m_notifications[2];
int m_activeNotificationsBufferIndex; int m_activeNotificationsBufferIndex;
int m_activeRendererPluginUid; int m_activeRendererPluginUid;
int m_numNotificationPlugins;
b3PluginManagerInternalData() b3PluginManagerInternalData()
:m_activeNotificationsBufferIndex(0), m_activeRendererPluginUid(-1) :m_activeNotificationsBufferIndex(0), m_activeRendererPluginUid(-1),
m_numNotificationPlugins(0)
{ {
} }
}; };
@@ -149,9 +151,12 @@ void b3PluginManager::clearEvents()
} }
void b3PluginManager::addNotification(const struct b3Notification& notification) void b3PluginManager::addNotification(const struct b3Notification& notification)
{
if (m_data->m_numNotificationPlugins>0)
{ {
m_data->m_notifications[m_data->m_activeNotificationsBufferIndex].push_back(notification); m_data->m_notifications[m_data->m_activeNotificationsBufferIndex].push_back(notification);
} }
}
int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr) int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
{ {
@@ -187,8 +192,14 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
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_processNotificationsFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, processNotificationsStr.c_str()); plugin->m_processNotificationsFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, processNotificationsStr.c_str());
if (plugin->m_processNotificationsFunc)
{
m_data->m_numNotificationPlugins++;
}
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)
{ {
@@ -251,6 +262,10 @@ void b3PluginManager::unloadPlugin(int pluginUniqueId)
b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId); b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId);
if (plugin) if (plugin)
{ {
if (plugin->m_processNotificationsFunc)
{
m_data->m_numNotificationPlugins--;
}
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;
@@ -373,6 +388,11 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT
pluginHandle->m_userPointer = 0; pluginHandle->m_userPointer = 0;
if (pluginHandle->m_processNotificationsFunc)
{
m_data->m_numNotificationPlugins++;
}
m_data->m_pluginMap.insert(pluginPath, pluginUniqueId); m_data->m_pluginMap.insert(pluginPath, pluginUniqueId);
{ {

View File

@@ -135,6 +135,7 @@ private:
if (cmdPtr) if (cmdPtr)
{ {
bool hasStatus = m_comProc->processCommand(*cmdPtr, serverStatus, &buffer[0], buffer.size()); bool hasStatus = m_comProc->processCommand(*cmdPtr, serverStatus, &buffer[0], buffer.size());
m_comProc->reportNotifications();
double timeOutInSeconds = 10; double timeOutInSeconds = 10;
b3Clock clock; b3Clock clock;
double startTimeSeconds = clock.getTimeInSeconds(); double startTimeSeconds = clock.getTimeInSeconds();

View File

@@ -62,8 +62,9 @@ def run():
print("PyBullet client received: " , response) print("PyBullet client received: " , response)
i=0
for i in range (1000): while(True):
i=i+1
print("submit StepSimulationCommand: ", i) print("submit StepSimulationCommand: ", i)
response = stub.SubmitCommand(pybullet_pb2.PyBulletCommand(stepSimulationCommand=pybullet_pb2.StepSimulationCommand())) response = stub.SubmitCommand(pybullet_pb2.PyBulletCommand(stepSimulationCommand=pybullet_pb2.StepSimulationCommand()))
print("PyBullet client received: " , response.statusType) print("PyBullet client received: " , response.statusType)