run GUI on main thread for Mac OSX/__APPLE__, due to OS limitation
add b3CreateInProcessPhysicsServerAndConnectMainThread to test.c
This commit is contained in:
@@ -176,25 +176,6 @@
|
|||||||
|
|
||||||
language "C++"
|
language "C++"
|
||||||
|
|
||||||
if _OPTIONS["no-bullet3"] then
|
|
||||||
print "--no-bullet3 implies --no-demos"
|
|
||||||
_OPTIONS["no-demos"] = "1"
|
|
||||||
else
|
|
||||||
include "../src/Bullet3Common"
|
|
||||||
include "../src/Bullet3Geometry"
|
|
||||||
include "../src/Bullet3Collision"
|
|
||||||
include "../src/Bullet3Dynamics"
|
|
||||||
include "../src/Bullet3OpenCL"
|
|
||||||
include "../src/Bullet3Serialize/Bullet2FileLoader"
|
|
||||||
end
|
|
||||||
|
|
||||||
if _OPTIONS["no-extras"] then
|
|
||||||
print "--no-extras implies --no-demos"
|
|
||||||
_OPTIONS["no-demos"] = "1"
|
|
||||||
else
|
|
||||||
include "../Extras"
|
|
||||||
end
|
|
||||||
|
|
||||||
if not _OPTIONS["no-demos"] then
|
if not _OPTIONS["no-demos"] then
|
||||||
include "../examples/ExampleBrowser"
|
include "../examples/ExampleBrowser"
|
||||||
include "../examples/OpenGLWindow"
|
include "../examples/OpenGLWindow"
|
||||||
@@ -221,6 +202,25 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if _OPTIONS["no-bullet3"] then
|
||||||
|
print "--no-bullet3 implies --no-demos"
|
||||||
|
_OPTIONS["no-demos"] = "1"
|
||||||
|
else
|
||||||
|
include "../src/Bullet3Common"
|
||||||
|
include "../src/Bullet3Geometry"
|
||||||
|
include "../src/Bullet3Collision"
|
||||||
|
include "../src/Bullet3Dynamics"
|
||||||
|
include "../src/Bullet3OpenCL"
|
||||||
|
include "../src/Bullet3Serialize/Bullet2FileLoader"
|
||||||
|
end
|
||||||
|
|
||||||
|
if _OPTIONS["no-extras"] then
|
||||||
|
print "--no-extras implies --no-demos"
|
||||||
|
_OPTIONS["no-demos"] = "1"
|
||||||
|
else
|
||||||
|
include "../Extras"
|
||||||
|
end
|
||||||
|
|
||||||
if not _OPTIONS["no-test"] then
|
if not _OPTIONS["no-test"] then
|
||||||
include "../test/Bullet2"
|
include "../test/Bullet2"
|
||||||
|
|
||||||
|
|||||||
@@ -229,3 +229,46 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* data)
|
|||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct btInProcessExampleBrowserMainThreadInternalData
|
||||||
|
{
|
||||||
|
ExampleEntries m_examples;
|
||||||
|
DefaultBrowser* m_exampleBrowser;
|
||||||
|
SharedMemoryInterface* m_sharedMem;
|
||||||
|
b3Clock m_clock;
|
||||||
|
};
|
||||||
|
|
||||||
|
btInProcessExampleBrowserMainThreadInternalData* btCreateInProcessExampleBrowserMainThread(int argc,char** argv)
|
||||||
|
{
|
||||||
|
btInProcessExampleBrowserMainThreadInternalData* data = new btInProcessExampleBrowserMainThreadInternalData;
|
||||||
|
data->m_examples.initExampleEntries();
|
||||||
|
data->m_exampleBrowser = new DefaultBrowser(&data->m_examples);
|
||||||
|
data->m_sharedMem = new InProcessMemory;
|
||||||
|
data->m_exampleBrowser->setSharedMemoryInterface(data->m_sharedMem );
|
||||||
|
bool init = data->m_exampleBrowser->init(argc,argv);
|
||||||
|
data->m_clock.reset();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool btIsExampleBrowserMainThreadTerminated(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||||
|
{
|
||||||
|
return data->m_exampleBrowser->requestedExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void btUpdateInProcessExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||||
|
{
|
||||||
|
float deltaTimeInSeconds = data->m_clock.getTimeMicroseconds()/1000000.f;
|
||||||
|
data->m_clock.reset();
|
||||||
|
data->m_exampleBrowser->update(deltaTimeInSeconds);
|
||||||
|
}
|
||||||
|
void btShutDownExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||||
|
{
|
||||||
|
|
||||||
|
data->m_exampleBrowser->setSharedMemoryInterface(0);
|
||||||
|
delete data->m_exampleBrowser;
|
||||||
|
delete data;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SharedMemoryInterface* btGetSharedMemoryInterfaceMainThread(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||||
|
{
|
||||||
|
return data->m_sharedMem;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,4 +12,22 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* data);
|
|||||||
class SharedMemoryInterface* btGetSharedMemoryInterface(btInProcessExampleBrowserInternalData* data);
|
class SharedMemoryInterface* btGetSharedMemoryInterface(btInProcessExampleBrowserInternalData* data);
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
struct btInProcessExampleBrowserMainThreadInternalData;
|
||||||
|
|
||||||
|
btInProcessExampleBrowserMainThreadInternalData* btCreateInProcessExampleBrowserMainThread(int argc,char** argv2);
|
||||||
|
|
||||||
|
bool btIsExampleBrowserMainThreadTerminated(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||||
|
|
||||||
|
void btUpdateInProcessExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||||
|
|
||||||
|
void btShutDownExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||||
|
|
||||||
|
class SharedMemoryInterface* btGetSharedMemoryInterfaceMainThread(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
|
||||||
#endif //IN_PROCESS_EXAMPLE_BROWSER_H
|
#endif //IN_PROCESS_EXAMPLE_BROWSER_H
|
||||||
|
|||||||
@@ -1,4 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "InProcessExampleBrowserMainThread.h"
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
btInProcessExampleBrowserMainThreadInternalData* data = btCreateInProcessExampleBrowserMainThread(argc,argv);
|
||||||
|
|
||||||
|
while (!btIsExampleBrowserMainThreadTerminated(data))
|
||||||
|
{
|
||||||
|
btUpdateInProcessExampleBrowserMainThread(data, 1./60.);
|
||||||
|
}
|
||||||
|
btShutDownExampleBrowserMainThread(data);
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
//#define EXAMPLE_CONSOLE_ONLY
|
//#define EXAMPLE_CONSOLE_ONLY
|
||||||
#ifdef EXAMPLE_CONSOLE_ONLY
|
#ifdef EXAMPLE_CONSOLE_ONLY
|
||||||
#include "EmptyBrowser.h"
|
#include "EmptyBrowser.h"
|
||||||
@@ -43,3 +63,4 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
@@ -1,3 +1,61 @@
|
|||||||
|
project "App_BulletExampleBrowser"
|
||||||
|
|
||||||
|
language "C++"
|
||||||
|
|
||||||
|
kind "ConsoleApp"
|
||||||
|
|
||||||
|
hasCL = findOpenCL("clew")
|
||||||
|
|
||||||
|
if (hasCL) then
|
||||||
|
|
||||||
|
-- project ("App_Bullet3_OpenCL_Demos_" .. vendor)
|
||||||
|
|
||||||
|
initOpenCL("clew")
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
links{"BulletExampleBrowserLib","gwen", "OpenGL_Window","BulletSoftBody", "BulletInverseDynamicsUtils", "BulletInverseDynamics", "BulletDynamics","BulletCollision","LinearMath","Bullet3Common"}
|
||||||
|
initOpenGL()
|
||||||
|
initGlew()
|
||||||
|
|
||||||
|
includedirs {
|
||||||
|
".",
|
||||||
|
"../../src",
|
||||||
|
"../ThirdPartyLibs",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if os.is("MacOSX") then
|
||||||
|
links{"Cocoa.framework"}
|
||||||
|
end
|
||||||
|
|
||||||
|
if (hasCL) then
|
||||||
|
links {
|
||||||
|
"Bullet3OpenCL_clew",
|
||||||
|
"Bullet3Dynamics",
|
||||||
|
"Bullet3Collision",
|
||||||
|
"Bullet3Geometry",
|
||||||
|
"Bullet3Common",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
if _OPTIONS["lua"] then
|
||||||
|
includedirs{"../ThirdPartyLibs/lua-5.2.3/src"}
|
||||||
|
links {"lua-5.2.3"}
|
||||||
|
defines {"ENABLE_LUA"}
|
||||||
|
files {"../LuaDemo/LuaPhysicsSetup.cpp"}
|
||||||
|
end
|
||||||
|
|
||||||
|
files {
|
||||||
|
"main.cpp",
|
||||||
|
"ExampleEntries.cpp",
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.is("Linux") then
|
||||||
|
initX11()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
project "BulletExampleBrowserLib"
|
project "BulletExampleBrowserLib"
|
||||||
|
|
||||||
@@ -145,61 +203,4 @@ if os.is("Linux") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
project "App_BulletExampleBrowser"
|
|
||||||
|
|
||||||
language "C++"
|
|
||||||
|
|
||||||
kind "ConsoleApp"
|
|
||||||
|
|
||||||
hasCL = findOpenCL("clew")
|
|
||||||
|
|
||||||
if (hasCL) then
|
|
||||||
|
|
||||||
-- project ("App_Bullet3_OpenCL_Demos_" .. vendor)
|
|
||||||
|
|
||||||
initOpenCL("clew")
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
links{"BulletExampleBrowserLib","gwen", "OpenGL_Window","BulletSoftBody", "BulletInverseDynamicsUtils", "BulletInverseDynamics", "BulletDynamics","BulletCollision","LinearMath","Bullet3Common"}
|
|
||||||
initOpenGL()
|
|
||||||
initGlew()
|
|
||||||
|
|
||||||
includedirs {
|
|
||||||
".",
|
|
||||||
"../../src",
|
|
||||||
"../ThirdPartyLibs",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if os.is("MacOSX") then
|
|
||||||
links{"Cocoa.framework"}
|
|
||||||
end
|
|
||||||
|
|
||||||
if (hasCL) then
|
|
||||||
links {
|
|
||||||
"Bullet3OpenCL_clew",
|
|
||||||
"Bullet3Dynamics",
|
|
||||||
"Bullet3Collision",
|
|
||||||
"Bullet3Geometry",
|
|
||||||
"Bullet3Common",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
if _OPTIONS["lua"] then
|
|
||||||
includedirs{"../ThirdPartyLibs/lua-5.2.3/src"}
|
|
||||||
links {"lua-5.2.3"}
|
|
||||||
defines {"ENABLE_LUA"}
|
|
||||||
files {"../LuaDemo/LuaPhysicsSetup.cpp"}
|
|
||||||
end
|
|
||||||
|
|
||||||
files {
|
|
||||||
"main.cpp",
|
|
||||||
"ExampleEntries.cpp",
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.is("Linux") then
|
|
||||||
initX11()
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,63 @@
|
|||||||
|
|
||||||
#include "SharedMemoryInProcessPhysicsC_API.h"
|
#include "SharedMemoryInProcessPhysicsC_API.h"
|
||||||
|
|
||||||
#include "PhysicsClientSharedMemory.h"
|
#include "PhysicsClientSharedMemory.h"
|
||||||
#include"../ExampleBrowser/InProcessExampleBrowser.h"
|
#include"../ExampleBrowser/InProcessExampleBrowser.h"
|
||||||
|
#include"../ExampleBrowser/InProcessExampleBrowserMainThread.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class InProcessPhysicsClientSharedMemoryMainThread : public PhysicsClientSharedMemory
|
||||||
|
{
|
||||||
|
btInProcessExampleBrowserMainThreadInternalData* m_data;
|
||||||
|
public:
|
||||||
|
|
||||||
|
InProcessPhysicsClientSharedMemoryMainThread(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
int newargc = argc+2;
|
||||||
|
char** newargv = (char**)malloc(sizeof(void*)*newargc);
|
||||||
|
for (int i=0;i<argc;i++)
|
||||||
|
newargv[i] = argv[i];
|
||||||
|
|
||||||
|
char* t0 = (char*)"--logtostderr";
|
||||||
|
char* t1 = (char*)"--start_demo_name=Physics Server";
|
||||||
|
newargv[argc] = t0;
|
||||||
|
newargv[argc+1] = t1;
|
||||||
|
m_data = btCreateInProcessExampleBrowserMainThread(newargc,newargv);
|
||||||
|
SharedMemoryInterface* shMem = btGetSharedMemoryInterfaceMainThread(m_data);
|
||||||
|
|
||||||
|
setSharedMemoryInterface(shMem);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~InProcessPhysicsClientSharedMemoryMainThread()
|
||||||
|
{
|
||||||
|
setSharedMemoryInterface(0);
|
||||||
|
btShutDownExampleBrowserMainThread(m_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return non-null if there is a status, nullptr otherwise
|
||||||
|
virtual const struct SharedMemoryStatus* processServerStatus()
|
||||||
|
{
|
||||||
|
btUpdateInProcessExampleBrowserMainThread(m_data);
|
||||||
|
return PhysicsClientSharedMemory::processServerStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool submitClientCommand(const struct SharedMemoryCommand& command)
|
||||||
|
{
|
||||||
|
// btUpdateInProcessExampleBrowserMainThread(m_data);
|
||||||
|
return PhysicsClientSharedMemory::submitClientCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
InProcessPhysicsClientSharedMemoryMainThread* cl = new InProcessPhysicsClientSharedMemoryMainThread(argc, argv);
|
||||||
|
cl->setSharedMemoryKey(SHARED_MEMORY_KEY);
|
||||||
|
cl->connect();
|
||||||
|
return (b3PhysicsClientHandle ) cl;
|
||||||
|
}
|
||||||
|
|
||||||
class InProcessPhysicsClientSharedMemory : public PhysicsClientSharedMemory
|
class InProcessPhysicsClientSharedMemory : public PhysicsClientSharedMemory
|
||||||
{
|
{
|
||||||
btInProcessExampleBrowserInternalData* m_data;
|
btInProcessExampleBrowserInternalData* m_data;
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ extern "C" {
|
|||||||
///think more about naming. The b3ConnectPhysicsLoopback
|
///think more about naming. The b3ConnectPhysicsLoopback
|
||||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]);
|
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]);
|
||||||
|
|
||||||
|
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -241,7 +241,12 @@ int main(int argc, char* argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PHYSICS_IN_PROCESS_EXAMPLE_BROWSER
|
#ifdef PHYSICS_IN_PROCESS_EXAMPLE_BROWSER
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
b3PhysicsClientHandle sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc,argv);
|
||||||
|
#else
|
||||||
b3PhysicsClientHandle sm = b3CreateInProcessPhysicsServerAndConnect(argc,argv);
|
b3PhysicsClientHandle sm = b3CreateInProcessPhysicsServerAndConnect(argc,argv);
|
||||||
|
#endif //__APPLE__
|
||||||
#endif
|
#endif
|
||||||
#ifdef PHYSICS_SHARED_MEMORY
|
#ifdef PHYSICS_SHARED_MEMORY
|
||||||
b3PhysicsClientHandle sm = b3ConnectSharedMemory(SHARED_MEMORY_KEY);
|
b3PhysicsClientHandle sm = b3ConnectSharedMemory(SHARED_MEMORY_KEY);
|
||||||
|
|||||||
Reference in New Issue
Block a user