MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / loadPlugin

Method loadPlugin

examples/SharedMemory/b3PluginManager.cpp:199–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199int b3PluginManager::loadPlugin(const char* pluginPath, const char* postFixStr)
200{
201 int pluginUniqueId = -1;
202
203 int* pluginUidPtr = m_data->m_pluginMap.find(b3Plugin::GetMapKey(pluginPath, postFixStr));
204 if (pluginUidPtr)
205 {
206 //already loaded
207 pluginUniqueId = *pluginUidPtr;
208 b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId);
209 if (!plugin->m_isInitialized)
210 {
211 b3PluginContext context = {0};
212 context.m_userPointer = 0;
213 context.m_physClient = (b3PhysicsClientHandle)m_data->m_physicsDirect;
214 context.m_rpcCommandProcessorInterface = m_data->m_rpcCommandProcessorInterface;
215 int result = plugin->m_initFunc(&context);
216 plugin->m_isInitialized = true;
217 plugin->m_userPointer = context.m_userPointer;
218 }
219 }
220 else
221 {
222 pluginUniqueId = m_data->m_plugins.allocHandle();
223 b3PluginHandle* plugin = m_data->m_plugins.getHandle(pluginUniqueId);
224 plugin->m_pluginUniqueId = pluginUniqueId;
225 B3_DYNLIB_HANDLE pluginHandle = B3_DYNLIB_OPEN(pluginPath);
226 bool ok = false;
227 if (pluginHandle)
228 {
229 std::string postFix = postFixStr;
230 std::string initStr = std::string("initPlugin") + postFix;
231 std::string exitStr = std::string("exitPlugin") + postFix;
232 std::string executePluginCommandStr = std::string("executePluginCommand") + postFix;
233 std::string preTickPluginCallbackStr = std::string("preTickPluginCallback") + postFix;
234 std::string postTickPluginCallback = std::string("postTickPluginCallback") + postFix;
235 std::string processNotificationsStr = std::string("processNotifications") + postFix;
236 std::string processClientCommandsStr = std::string("processClientCommands") + postFix;
237 std::string getRendererStr = std::string("getRenderInterface") + postFix;
238 std::string getCollisionStr = std::string("getCollisionInterface") + postFix;
239 std::string getFileIOStr = std::string("getFileIOInterface") + postFix;
240
241 plugin->m_initFunc = (PFN_INIT)B3_DYNLIB_IMPORT(pluginHandle, initStr.c_str());
242 plugin->m_exitFunc = (PFN_EXIT)B3_DYNLIB_IMPORT(pluginHandle, exitStr.c_str());
243 plugin->m_executeCommandFunc = (PFN_EXECUTE)B3_DYNLIB_IMPORT(pluginHandle, executePluginCommandStr.c_str());
244 plugin->m_preTickFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, preTickPluginCallbackStr.c_str());
245 plugin->m_postTickFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, postTickPluginCallback.c_str());
246 plugin->m_processNotificationsFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, processNotificationsStr.c_str());
247
248 if (plugin->m_processNotificationsFunc)
249 {
250 m_data->m_numNotificationPlugins++;
251 }
252 plugin->m_processClientCommandsFunc = (PFN_TICK)B3_DYNLIB_IMPORT(pluginHandle, processClientCommandsStr.c_str());
253
254 plugin->m_getRendererFunc = (PFN_GET_RENDER_INTERFACE)B3_DYNLIB_IMPORT(pluginHandle, getRendererStr.c_str());
255 plugin->m_getCollisionFunc = (PFN_GET_COLLISION_INTERFACE)B3_DYNLIB_IMPORT(pluginHandle, getCollisionStr.c_str());
256 plugin->m_getFileIOFunc = (PFN_GET_FILEIO_INTERFACE)B3_DYNLIB_IMPORT(pluginHandle, getFileIOStr.c_str());

Callers 15

threecubes.pyFile · 0.80
threecubes_org.pyFile · 0.80
grpcServer.pyFile · 0.80
renderPlugin.pyFile · 0.80
testrender.pyFile · 0.80
rendertest.pyFile · 0.80
fileIOPlugin.pyFile · 0.80
__init__Method · 0.80
testPlugin.pyFile · 0.80
testrender_egl.pyFile · 0.80

Calls 7

c_strMethod · 0.80
GetMapKeyMethod · 0.80
findMethod · 0.45
getHandleMethod · 0.45
allocHandleMethod · 0.45
insertMethod · 0.45
freeHandleMethod · 0.45

Tested by 1

__init__Method · 0.64