From a66576f0341b4aa17d389a07d298aa3aff9f6202 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 16 Aug 2017 12:33:25 -0700 Subject: [PATCH] revert API to be backward compatible, add b3CreateInProcessPhysicsServerAndConnectSharedMemory same for BulletURDFImporter constructor --- .../ImportURDFDemo/BulletUrdfImporter.h | 2 +- .../b3RobotSimulatorClientAPI.cpp | 8 +++--- .../SharedMemoryInProcessPhysicsC_API.cpp | 26 ++++++++++++++++--- .../SharedMemoryInProcessPhysicsC_API.h | 6 +++-- examples/pybullet/pybullet.c | 8 +++--- 5 files changed, 35 insertions(+), 15 deletions(-) diff --git a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.h b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.h index c26d30184..243e1e55c 100644 --- a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.h +++ b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.h @@ -15,7 +15,7 @@ class BulletURDFImporter : public URDFImporterInterface public: - BulletURDFImporter(struct GUIHelperInterface* helper, LinkVisualShapesConverter* customConverter, btScalar globalScaling); + BulletURDFImporter(struct GUIHelperInterface* helper, LinkVisualShapesConverter* customConverter, btScalar globalScaling=1); virtual ~BulletURDFImporter(); diff --git a/examples/RobotSimulator/b3RobotSimulatorClientAPI.cpp b/examples/RobotSimulator/b3RobotSimulatorClientAPI.cpp index 73c7e30e6..172a8dfb9 100644 --- a/examples/RobotSimulator/b3RobotSimulatorClientAPI.cpp +++ b/examples/RobotSimulator/b3RobotSimulatorClientAPI.cpp @@ -129,9 +129,9 @@ bool b3RobotSimulatorClientAPI::connect(int mode, const std::string& hostName, i int argc = 0; char* argv[1] = {0}; #ifdef __APPLE__ - sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,1); + sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv); #else - sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,1); + sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv); #endif break; } @@ -140,9 +140,9 @@ bool b3RobotSimulatorClientAPI::connect(int mode, const std::string& hostName, i int argc = 0; char* argv[1] = {0}; #ifdef __APPLE__ - sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,0); + sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv); #else - sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,0); + sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv); #endif break; } diff --git a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp index 2def80e1c..8f01bfb5a 100644 --- a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp +++ b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp @@ -83,14 +83,24 @@ public: }; -b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[], int useInProcessMemory) +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[]) { - InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv, useInProcessMemory); + InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv, 1); cl->setSharedMemoryKey(SHARED_MEMORY_KEY); cl->connect(); return (b3PhysicsClientHandle ) cl; } +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(int argc, char* argv[]) +{ + InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv, 0); + cl->setSharedMemoryKey(SHARED_MEMORY_KEY); + cl->connect(); + return (b3PhysicsClientHandle ) cl; +} + + + class InProcessPhysicsClientSharedMemory : public PhysicsClientSharedMemory { btInProcessExampleBrowserInternalData* m_data; @@ -123,10 +133,18 @@ public: }; -b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[], int useInProcessMemory) +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]) { - InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv, useInProcessMemory); + InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv, 1); + cl->setSharedMemoryKey(SHARED_MEMORY_KEY+1); + cl->connect(); + return (b3PhysicsClientHandle ) cl; +} +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectSharedMemory(int argc, char* argv[]) +{ + + InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv, 0); cl->setSharedMemoryKey(SHARED_MEMORY_KEY+1); cl->connect(); return (b3PhysicsClientHandle ) cl; diff --git a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h index 0bad1283a..04acba313 100644 --- a/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h +++ b/examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h @@ -10,9 +10,11 @@ extern "C" { ///think more about naming. The b3ConnectPhysicsLoopback -b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[], int useInProcessMemory); +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]); +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectSharedMemory(int argc, char* argv[]); -b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[], int useInProcessMemory); +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[]); +b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(int argc, char* argv[]); b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect(void* guiHelperPtr); diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index f1f2b1996..6f791de14 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -355,9 +355,9 @@ static PyObject* pybullet_connectPhysicsServer(PyObject* self, PyObject* args, P char* argv[2] = {"unused",options}; #ifdef __APPLE__ - sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,1); + sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv); #else - sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,1); + sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv); #endif break; } @@ -367,9 +367,9 @@ static PyObject* pybullet_connectPhysicsServer(PyObject* self, PyObject* args, P char* argv[2] = {"unused",options}; #ifdef __APPLE__ - sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,0); + sm = b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(argc, argv); #else - sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,0); + sm = b3CreateInProcessPhysicsServerAndConnectSharedMemory(argc, argv); #endif break; }