only add notifications if there is a plugin that needs them
call the 'reportNotifications' in GRPC server main
This commit is contained in:
@@ -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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -150,7 +152,10 @@ void b3PluginManager::clearEvents()
|
|||||||
|
|
||||||
void b3PluginManager::addNotification(const struct b3Notification& notification)
|
void b3PluginManager::addNotification(const struct b3Notification& notification)
|
||||||
{
|
{
|
||||||
m_data->m_notifications[m_data->m_activeNotificationsBufferIndex].push_back(notification);
|
if (m_data->m_numNotificationPlugins>0)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user