revert API to be backward compatible, add b3CreateInProcessPhysicsServerAndConnectSharedMemory

same for BulletURDFImporter constructor
This commit is contained in:
Erwin Coumans
2017-08-16 12:33:25 -07:00
parent b7579cbdda
commit a66576f034
5 changed files with 35 additions and 15 deletions

View File

@@ -15,7 +15,7 @@ class BulletURDFImporter : public URDFImporterInterface
public: public:
BulletURDFImporter(struct GUIHelperInterface* helper, LinkVisualShapesConverter* customConverter, btScalar globalScaling); BulletURDFImporter(struct GUIHelperInterface* helper, LinkVisualShapesConverter* customConverter, btScalar globalScaling=1);
virtual ~BulletURDFImporter(); virtual ~BulletURDFImporter();

View File

@@ -129,9 +129,9 @@ bool b3RobotSimulatorClientAPI::connect(int mode, const std::string& hostName, i
int argc = 0; int argc = 0;
char* argv[1] = {0}; char* argv[1] = {0};
#ifdef __APPLE__ #ifdef __APPLE__
sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,1); sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv);
#else #else
sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,1); sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv);
#endif #endif
break; break;
} }
@@ -140,9 +140,9 @@ bool b3RobotSimulatorClientAPI::connect(int mode, const std::string& hostName, i
int argc = 0; int argc = 0;
char* argv[1] = {0}; char* argv[1] = {0};
#ifdef __APPLE__ #ifdef __APPLE__
sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,0); sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv);
#else #else
sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,0); sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv);
#endif #endif
break; break;
} }

View File

@@ -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->setSharedMemoryKey(SHARED_MEMORY_KEY);
cl->connect(); cl->connect();
return (b3PhysicsClientHandle ) cl; 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 class InProcessPhysicsClientSharedMemory : public PhysicsClientSharedMemory
{ {
btInProcessExampleBrowserInternalData* m_data; 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->setSharedMemoryKey(SHARED_MEMORY_KEY+1);
cl->connect(); cl->connect();
return (b3PhysicsClientHandle ) cl; return (b3PhysicsClientHandle ) cl;

View File

@@ -10,9 +10,11 @@ extern "C" {
///think more about naming. The b3ConnectPhysicsLoopback ///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); b3PhysicsClientHandle b3CreateInProcessPhysicsServerFromExistingExampleBrowserAndConnect(void* guiHelperPtr);

View File

@@ -355,9 +355,9 @@ static PyObject* pybullet_connectPhysicsServer(PyObject* self, PyObject* args, P
char* argv[2] = {"unused",options}; char* argv[2] = {"unused",options};
#ifdef __APPLE__ #ifdef __APPLE__
sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,1); sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv);
#else #else
sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,1); sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv);
#endif #endif
break; break;
} }
@@ -367,9 +367,9 @@ static PyObject* pybullet_connectPhysicsServer(PyObject* self, PyObject* args, P
char* argv[2] = {"unused",options}; char* argv[2] = {"unused",options};
#ifdef __APPLE__ #ifdef __APPLE__
sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc, argv,0); sm = b3CreateInProcessPhysicsServerAndConnectMainThreadSharedMemory(argc, argv);
#else #else
sm = b3CreateInProcessPhysicsServerAndConnect(argc, argv,0); sm = b3CreateInProcessPhysicsServerAndConnectSharedMemory(argc, argv);
#endif #endif
break; break;
} }