add physics server loopback (both client and server in the same process, using shared memory)

add physics server direct (client and server in the same process, directly processing commands without shared memory transport mechanism)
This commit is contained in:
erwincoumans
2015-11-22 20:50:32 -08:00
parent 7d6c2b77f7
commit 03bf78ef49
23 changed files with 2914 additions and 2086 deletions

View File

@@ -26,7 +26,7 @@ project ("Test_SharedMemoryPhysicsClient")
"../../examples/Utils/b3ResourcePath.h",
}
project ("Test_PhysicsLoopBack")
project ("Test_PhysicsServerLoopBack")
language "C++"
kind "ConsoleApp"
@@ -49,6 +49,10 @@ project ("Test_PhysicsLoopBack")
"../../examples/SharedMemory/PhysicsClient.h",
"../../examples/SharedMemory/PhysicsServer.cpp",
"../../examples/SharedMemory/PhysicsServer.h",
"../../examples/SharedMemory/PhysicsServerSharedMemory.cpp",
"../../examples/SharedMemory/PhysicsServerSharedMemory.h",
"../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp",
"../../examples/SharedMemory/PhysicsServerCommandProcessor.h",
"../../examples/SharedMemory/PhysicsLoopBack.cpp",
"../../examples/SharedMemory/PhysicsLoopBack.h",
"../../examples/SharedMemory/PhysicsLoopBackC_Api.cpp",
@@ -79,3 +83,62 @@ project ("Test_PhysicsLoopBack")
"../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp",
}
project ("Test_PhysicsServerDirect")
language "C++"
kind "ConsoleApp"
includedirs {"../../src", "../../examples/SharedMemory",
"../../examples/ThirdPartyLibs"}
defines {"PHYSICS_SERVER_DIRECT"}
links {
"BulletFileLoader",
"BulletWorldImporter",
"Bullet3Common",
"BulletDynamics",
"BulletCollision",
"LinearMath"
}
files {
"test.c",
"../../examples/SharedMemory/PhysicsClient.cpp",
"../../examples/SharedMemory/PhysicsClient.h",
"../../examples/SharedMemory/PhysicsServer.cpp",
"../../examples/SharedMemory/PhysicsServer.h",
"../../examples/SharedMemory/PhysicsServerSharedMemory.cpp",
"../../examples/SharedMemory/PhysicsServerSharedMemory.h",
"../../examples/SharedMemory/PhysicsDirect.cpp",
"../../examples/SharedMemory/PhysicsDirect.h",
"../../examples/SharedMemory/PhysicsDirectC_API.cpp",
"../../examples/SharedMemory/PhysicsDirectC_API.h",
"../../examples/SharedMemory/PhysicsServerCommandProcessor.cpp",
"../../examples/SharedMemory/PhysicsServerCommandProcessor.h",
"../../examples/SharedMemory/PhysicsClientSharedMemory.cpp",
"../../examples/SharedMemory/PhysicsClientSharedMemory.h",
"../../examples/SharedMemory/PhysicsClientC_API.cpp",
"../../examples/SharedMemory/PhysicsClientC_API.h",
"../../examples/SharedMemory/Win32SharedMemory.cpp",
"../../examples/SharedMemory/Win32SharedMemory.h",
"../../examples/SharedMemory/PosixSharedMemory.cpp",
"../../examples/SharedMemory/PosixSharedMemory.h",
"../../examples/Utils/b3ResourcePath.cpp",
"../../examples/Utils/b3ResourcePath.h",
"../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp",
"../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp",
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
"../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
"../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp",
"../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",
"../../examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp",
"../../examples/Importers/ImportURDFDemo/MyMultiBodyCreator.cpp",
"../../examples/Importers/ImportURDFDemo/URDF2Bullet.cpp",
"../../examples/Importers/ImportURDFDemo/UrdfParser.cpp",
"../../examples/Importers/ImportURDFDemo/urdfStringSplit.cpp",
}

View File

@@ -5,6 +5,11 @@
#include "PhysicsLoopBackC_API.h"
#endif //PHYSICS_LOOP_BACK
#ifdef PHYSICS_SERVER_DIRECT
#include "PhysicsDirectC_API.h"
#endif //PHYSICS_SERVER_DIRECT
#include "SharedMemoryPublic.h"
#include "Bullet3Common/b3Logging.h"
#include <string.h>
@@ -28,12 +33,17 @@ int main(int argc, char* argv[])
b3PhysicsClientHandle sm=0;
int bodyIndex = -1;
printf("hello world\n");
#ifdef PHYSICS_LOOP_BACK
sm = b3ConnectPhysicsLoopback(SHARED_MEMORY_KEY);
#else
sm = b3ConnectSharedMemory(SHARED_MEMORY_KEY);
#endif
#ifdef PHYSICS_SERVER_DIRECT
sm = b3ConnectPhysicsDirect();
#else//PHYSICS_SERVER_DIRECT
sm = b3ConnectSharedMemory(SHARED_MEMORY_KEY);
#endif //PHYSICS_SERVER_DIRECT