Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -7,27 +7,27 @@
|
||||
#include "plugins/b3PluginContext.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#include <windows.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#include <windows.h>
|
||||
|
||||
typedef HMODULE B3_DYNLIB_HANDLE;
|
||||
typedef HMODULE B3_DYNLIB_HANDLE;
|
||||
|
||||
#define B3_DYNLIB_OPEN LoadLibraryA
|
||||
#define B3_DYNLIB_CLOSE FreeLibrary
|
||||
#define B3_DYNLIB_IMPORT GetProcAddress
|
||||
#define B3_DYNLIB_OPEN LoadLibraryA
|
||||
#define B3_DYNLIB_CLOSE FreeLibrary
|
||||
#define B3_DYNLIB_IMPORT GetProcAddress
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef void* B3_DYNLIB_HANDLE;
|
||||
typedef void* B3_DYNLIB_HANDLE;
|
||||
|
||||
#ifdef B3_USE_DLMOPEN
|
||||
#define B3_DYNLIB_OPEN(path) dlmopen(LM_ID_NEWLM, path, RTLD_LAZY)
|
||||
#define B3_DYNLIB_OPEN(path) dlmopen(LM_ID_NEWLM, path, RTLD_LAZY)
|
||||
#else
|
||||
#define B3_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
|
||||
#define B3_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
|
||||
#endif
|
||||
#define B3_DYNLIB_CLOSE dlclose
|
||||
#define B3_DYNLIB_IMPORT dlsym
|
||||
#define B3_DYNLIB_CLOSE dlclose
|
||||
#define B3_DYNLIB_IMPORT dlsym
|
||||
#endif
|
||||
|
||||
struct b3Plugin
|
||||
@@ -52,20 +52,20 @@ struct b3Plugin
|
||||
void* m_userPointer;
|
||||
|
||||
b3Plugin()
|
||||
:m_pluginHandle(0),
|
||||
m_ownsPluginHandle(false),
|
||||
m_isInitialized(false),
|
||||
m_pluginUniqueId(-1),
|
||||
m_initFunc(0),
|
||||
m_exitFunc(0),
|
||||
m_executeCommandFunc(0),
|
||||
m_preTickFunc(0),
|
||||
m_postTickFunc(0),
|
||||
m_processNotificationsFunc(0),
|
||||
m_processClientCommandsFunc(0),
|
||||
m_getRendererFunc(0),
|
||||
m_getCollisionFunc(0),
|
||||
m_userPointer(0)
|
||||
: m_pluginHandle(0),
|
||||
m_ownsPluginHandle(false),
|
||||
m_isInitialized(false),
|
||||
m_pluginUniqueId(-1),
|
||||
m_initFunc(0),
|
||||
m_exitFunc(0),
|
||||
m_executeCommandFunc(0),
|
||||
m_preTickFunc(0),
|
||||
m_postTickFunc(0),
|
||||
m_processNotificationsFunc(0),
|
||||
m_processClientCommandsFunc(0),
|
||||
m_getRendererFunc(0),
|
||||
m_getCollisionFunc(0),
|
||||
m_userPointer(0)
|
||||
{
|
||||
}
|
||||
void clear()
|
||||
@@ -107,8 +107,7 @@ struct b3PluginManagerInternalData
|
||||
int m_numNotificationPlugins;
|
||||
|
||||
b3PluginManagerInternalData()
|
||||
:m_rpcCommandProcessorInterface(0), m_activeNotificationsBufferIndex(0), m_activeRendererPluginUid(-1),
|
||||
m_activeCollisionPluginUid(-1), m_numNotificationPlugins(0)
|
||||
: m_rpcCommandProcessorInterface(0), m_activeNotificationsBufferIndex(0), m_activeRendererPluginUid(-1), m_activeCollisionPluginUid(-1), m_numNotificationPlugins(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -117,8 +116,7 @@ b3PluginManager::b3PluginManager(class PhysicsCommandProcessorInterface* physSdk
|
||||
{
|
||||
m_data = new b3PluginManagerInternalData;
|
||||
m_data->m_rpcCommandProcessorInterface = physSdk;
|
||||
m_data->m_physicsDirect = new PhysicsDirect(physSdk,false);
|
||||
|
||||
m_data->m_physicsDirect = new PhysicsDirect(physSdk, false);
|
||||
}
|
||||
|
||||
b3PluginManager::~b3PluginManager()
|
||||
@@ -140,7 +138,6 @@ b3PluginManager::~b3PluginManager()
|
||||
|
||||
void b3PluginManager::addEvents(const struct b3VRControllerEvent* vrControllerEvents, int numVRControllerEvents, const struct b3KeyboardEvent* keyEvents, int numKeyEvents, const struct b3MouseEvent* mouseEvents, int numMouseEvents)
|
||||
{
|
||||
|
||||
for (int i = 0; i < numKeyEvents; i++)
|
||||
{
|
||||
m_data->m_keyEvents.push_back(keyEvents[i]);
|
||||
@@ -165,7 +162,7 @@ void b3PluginManager::clearEvents()
|
||||
|
||||
void b3PluginManager::addNotification(const struct b3Notification& notification)
|
||||
{
|
||||
if (m_data->m_numNotificationPlugins>0)
|
||||
if (m_data->m_numNotificationPlugins > 0)
|
||||
{
|
||||
m_data->m_notifications[m_data->m_activeNotificationsBufferIndex].push_back(notification);
|
||||
}
|
||||
@@ -178,7 +175,6 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
int* pluginUidPtr = m_data->m_pluginMap.find(pluginPath);
|
||||
if (pluginUidPtr)
|
||||
{
|
||||
|
||||
//already loaded
|
||||
pluginUniqueId = *pluginUidPtr;
|
||||
b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId);
|
||||
@@ -186,7 +182,7 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
{
|
||||
b3PluginContext context = {0};
|
||||
context.m_userPointer = 0;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
context.m_rpcCommandProcessorInterface = m_data->m_rpcCommandProcessorInterface;
|
||||
int result = plugin->m_initFunc(&context);
|
||||
plugin->m_isInitialized = true;
|
||||
@@ -212,7 +208,6 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
std::string processClientCommandsStr = std::string("processClientCommands") + postFix;
|
||||
std::string getRendererStr = std::string("getRenderInterface") + postFix;
|
||||
std::string getCollisionStr = std::string("getCollisionInterface") + postFix;
|
||||
|
||||
|
||||
plugin->m_initFunc = (PFN_INIT)B3_DYNLIB_IMPORT(pluginHandle, initStr.c_str());
|
||||
plugin->m_exitFunc = (PFN_EXIT)B3_DYNLIB_IMPORT(pluginHandle, exitStr.c_str());
|
||||
@@ -227,16 +222,14 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
}
|
||||
plugin->m_processClientCommandsFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, processClientCommandsStr.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());
|
||||
plugin->m_getCollisionFunc = (PFN_GET_COLLISION_INTERFACE)B3_DYNLIB_IMPORT(pluginHandle, getCollisionStr.c_str());
|
||||
|
||||
|
||||
if (plugin->m_initFunc && plugin->m_exitFunc && plugin->m_executeCommandFunc)
|
||||
{
|
||||
|
||||
b3PluginContext context;
|
||||
context.m_userPointer = plugin->m_userPointer;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
context.m_rpcCommandProcessorInterface = m_data->m_rpcCommandProcessorInterface;
|
||||
int version = plugin->m_initFunc(&context);
|
||||
plugin->m_isInitialized = true;
|
||||
@@ -244,7 +237,6 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
plugin->m_userPointer = context.m_userPointer;
|
||||
if (version == SHARED_MEMORY_MAGIC_NUMBER)
|
||||
{
|
||||
|
||||
ok = true;
|
||||
plugin->m_ownsPluginHandle = true;
|
||||
plugin->m_pluginHandle = pluginHandle;
|
||||
@@ -269,13 +261,11 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
b3Warning("Warning: couldn't load plugin %s\n", pluginPath);
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
b3Warning("Error: %s\n", dlerror() );
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#else
|
||||
b3Warning("Error: %s\n", dlerror());
|
||||
#endif
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
@@ -285,7 +275,7 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
}
|
||||
|
||||
//for now, automatically select the loaded plugin as active renderer.
|
||||
if (pluginUniqueId>=0)
|
||||
if (pluginUniqueId >= 0)
|
||||
{
|
||||
b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId);
|
||||
if (plugin && plugin->m_getRendererFunc)
|
||||
@@ -293,9 +283,9 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
selectPluginRenderer(pluginUniqueId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//for now, automatically select the loaded plugin as active collision plugin.
|
||||
if (pluginUniqueId>=0)
|
||||
if (pluginUniqueId >= 0)
|
||||
{
|
||||
b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId);
|
||||
if (plugin && plugin->m_getCollisionFunc)
|
||||
@@ -304,7 +294,6 @@ int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return pluginUniqueId;
|
||||
}
|
||||
|
||||
@@ -319,7 +308,7 @@ void b3PluginManager::unloadPlugin(int pluginUniqueId)
|
||||
}
|
||||
b3PluginContext context = {0};
|
||||
context.m_userPointer = plugin->m_userPointer;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
|
||||
if (plugin->m_isInitialized)
|
||||
{
|
||||
@@ -332,11 +321,9 @@ void b3PluginManager::unloadPlugin(int pluginUniqueId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickMode)
|
||||
{
|
||||
for (int i=0;i<m_data->m_pluginMap.size();i++)
|
||||
for (int i = 0; i < m_data->m_pluginMap.size(); i++)
|
||||
{
|
||||
int* pluginUidPtr = m_data->m_pluginMap.getAtIndex(i);
|
||||
b3PluginHandle* plugin = 0;
|
||||
@@ -351,7 +338,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM
|
||||
continue;
|
||||
}
|
||||
|
||||
PFN_TICK tick = 0;
|
||||
PFN_TICK tick = 0;
|
||||
switch (tickMode)
|
||||
{
|
||||
case B3_PRE_TICK_MODE:
|
||||
@@ -376,7 +363,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM
|
||||
|
||||
if (tick)
|
||||
{
|
||||
b3PluginContext context = { 0 };
|
||||
b3PluginContext context = {0};
|
||||
context.m_userPointer = plugin->m_userPointer;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
context.m_numMouseEvents = m_data->m_mouseEvents.size();
|
||||
@@ -397,7 +384,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM
|
||||
|
||||
void b3PluginManager::reportNotifications()
|
||||
{
|
||||
b3AlignedObjectArray<b3Notification> ¬ifications = m_data->m_notifications[m_data->m_activeNotificationsBufferIndex];
|
||||
b3AlignedObjectArray<b3Notification>& notifications = m_data->m_notifications[m_data->m_activeNotificationsBufferIndex];
|
||||
if (notifications.size() == 0)
|
||||
{
|
||||
return;
|
||||
@@ -406,7 +393,7 @@ void b3PluginManager::reportNotifications()
|
||||
// Swap notification buffers.
|
||||
m_data->m_activeNotificationsBufferIndex = 1 - m_data->m_activeNotificationsBufferIndex;
|
||||
|
||||
for (int i=0;i<m_data->m_pluginMap.size();i++)
|
||||
for (int i = 0; i < m_data->m_pluginMap.size(); i++)
|
||||
{
|
||||
int* pluginUidPtr = m_data->m_pluginMap.getAtIndex(i);
|
||||
b3PluginHandle* plugin = 0;
|
||||
@@ -421,10 +408,11 @@ void b3PluginManager::reportNotifications()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (plugin->m_processNotificationsFunc) {
|
||||
if (plugin->m_processNotificationsFunc)
|
||||
{
|
||||
b3PluginContext context = {0};
|
||||
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_notifications = notifications.size() ? ¬ifications[0] : 0;
|
||||
plugin->m_processNotificationsFunc(&context);
|
||||
@@ -442,7 +430,7 @@ int b3PluginManager::executePluginCommand(int pluginUniqueId, const b3PluginArgu
|
||||
{
|
||||
b3PluginContext context = {0};
|
||||
context.m_userPointer = plugin->m_userPointer;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
context.m_rpcCommandProcessorInterface = m_data->m_rpcCommandProcessorInterface;
|
||||
result = plugin->m_executeCommandFunc(&context, arguments);
|
||||
plugin->m_userPointer = context.m_userPointer;
|
||||
@@ -450,16 +438,14 @@ int b3PluginManager::executePluginCommand(int pluginUniqueId, const b3PluginArgu
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT initFunc,PFN_EXIT exitFunc, PFN_EXECUTE executeCommandFunc, PFN_TICK preTickFunc, PFN_TICK postTickFunc, PFN_GET_RENDER_INTERFACE getRendererFunc, PFN_TICK processClientCommandsFunc, PFN_GET_COLLISION_INTERFACE getCollisionFunc, bool initPlugin)
|
||||
int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT initFunc, PFN_EXIT exitFunc, PFN_EXECUTE executeCommandFunc, PFN_TICK preTickFunc, PFN_TICK postTickFunc, PFN_GET_RENDER_INTERFACE getRendererFunc, PFN_TICK processClientCommandsFunc, PFN_GET_COLLISION_INTERFACE getCollisionFunc, bool initPlugin)
|
||||
{
|
||||
|
||||
b3Plugin orgPlugin;
|
||||
|
||||
int pluginUniqueId = m_data->m_plugins.allocHandle();
|
||||
b3PluginHandle* pluginHandle = m_data->m_plugins.getHandle(pluginUniqueId);
|
||||
pluginHandle->m_pluginHandle = 0;
|
||||
pluginHandle->m_ownsPluginHandle =false;
|
||||
pluginHandle->m_ownsPluginHandle = false;
|
||||
pluginHandle->m_pluginUniqueId = pluginUniqueId;
|
||||
pluginHandle->m_executeCommandFunc = executeCommandFunc;
|
||||
pluginHandle->m_exitFunc = exitFunc;
|
||||
@@ -473,7 +459,6 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT
|
||||
pluginHandle->m_pluginPath = pluginPath;
|
||||
pluginHandle->m_userPointer = 0;
|
||||
|
||||
|
||||
if (pluginHandle->m_processNotificationsFunc)
|
||||
{
|
||||
m_data->m_numNotificationPlugins++;
|
||||
@@ -485,7 +470,7 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT
|
||||
{
|
||||
b3PluginContext context = {0};
|
||||
context.m_userPointer = 0;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
context.m_rpcCommandProcessorInterface = m_data->m_rpcCommandProcessorInterface;
|
||||
int result = pluginHandle->m_initFunc(&context);
|
||||
pluginHandle->m_isInitialized = true;
|
||||
@@ -503,14 +488,14 @@ UrdfRenderingInterface* b3PluginManager::getRenderInterface()
|
||||
{
|
||||
UrdfRenderingInterface* renderer = 0;
|
||||
|
||||
if (m_data->m_activeRendererPluginUid>=0)
|
||||
if (m_data->m_activeRendererPluginUid >= 0)
|
||||
{
|
||||
b3PluginHandle* plugin = m_data->m_plugins.getHandle(m_data->m_activeRendererPluginUid);
|
||||
if (plugin && plugin->m_getRendererFunc)
|
||||
{
|
||||
b3PluginContext context = {0};
|
||||
context.m_userPointer = plugin->m_userPointer;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
renderer = plugin->m_getRendererFunc(&context);
|
||||
}
|
||||
}
|
||||
@@ -525,17 +510,16 @@ void b3PluginManager::selectCollisionPlugin(int pluginUniqueId)
|
||||
struct b3PluginCollisionInterface* b3PluginManager::getCollisionInterface()
|
||||
{
|
||||
b3PluginCollisionInterface* collisionInterface = 0;
|
||||
if (m_data->m_activeCollisionPluginUid>=0)
|
||||
if (m_data->m_activeCollisionPluginUid >= 0)
|
||||
{
|
||||
b3PluginHandle* plugin = m_data->m_plugins.getHandle(m_data->m_activeCollisionPluginUid);
|
||||
if (plugin && plugin->m_getCollisionFunc)
|
||||
{
|
||||
b3PluginContext context = {0};
|
||||
context.m_userPointer = plugin->m_userPointer;
|
||||
context.m_physClient = (b3PhysicsClientHandle) m_data->m_physicsDirect;
|
||||
context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
|
||||
collisionInterface = plugin->m_getCollisionFunc(&context);
|
||||
}
|
||||
}
|
||||
return collisionInterface;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user