From e4cd88e24f0238de392f13d2a5c62e2f9cf73661 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 5 Jun 2018 11:36:54 +1000 Subject: [PATCH] PyBullet: allow to choose the shared memory key when starting SHARED_MEMORY_SERVER --- .../SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp | 8 ++++++-- examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h | 2 +- examples/pybullet/pybullet.c | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp index 37b51fcd6..16f625dbd 100644 --- a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp +++ b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp @@ -271,10 +271,13 @@ B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingEx return (b3PhysicsClientHandle ) cl; } -B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect2(void* guiHelperPtr) +extern int gSharedMemoryKey; + +B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect2(void* guiHelperPtr, int sharedMemoryKey) { static DummyGUIHelper noGfx; + gSharedMemoryKey = sharedMemoryKey; GUIHelperInterface* guiHelper = (GUIHelperInterface*) guiHelperPtr; if (!guiHelper) { @@ -283,7 +286,8 @@ B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistin bool useInprocessMemory = false; bool skipGraphicsUpdate = true; InProcessPhysicsClientExistingExampleBrowser* cl = new InProcessPhysicsClientExistingExampleBrowser(guiHelper, useInprocessMemory, skipGraphicsUpdate); - cl->setSharedMemoryKey(SHARED_MEMORY_KEY+1); + + cl->setSharedMemoryKey(sharedMemoryKey+1); cl->connect(); return (b3PhysicsClientHandle ) cl; } diff --git a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h index 994f26e7c..9c11a3f13 100644 --- a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h +++ b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h @@ -18,7 +18,7 @@ B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMain B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect(void* guiHelperPtr); //create a shared memory physics server, with a DummyGUIHelper (no graphics) -B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect2(void* guiHelperPtr); +B3_SHARED_API b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect2(void* guiHelperPtr, int sharedMemoryKey); ///ignore the following APIs, they are for internal use for example browser void b3InProcessRenderSceneInternal(b3PhysicsClientHandle clientHandle); diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index bef819a0f..9bc834204 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -399,7 +399,7 @@ static PyObject* pybullet_connectPhysicsServer(PyObject* self, PyObject* args, P } case eCONNECT_SHARED_MEMORY_SERVER: { - sm = b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect2(0); + sm = b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect2(0, key); break; } case eCONNECT_DIRECT: