mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-14 13:50:04 +00:00
Merge pull request #598 from erwincoumans/master
run GUI on main thread for Mac OSX/__APPLE__, due to OS limitation
This commit is contained in:
commit
889a113cca
@ -176,25 +176,6 @@
|
||||
|
||||
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
|
||||
include "../examples/ExampleBrowser"
|
||||
include "../examples/OpenGLWindow"
|
||||
@ -221,6 +202,25 @@
|
||||
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
|
||||
include "../test/Bullet2"
|
||||
|
||||
|
@ -229,3 +229,46 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* 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);
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
|
||||
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
|
||||
|
@ -1,5 +1,63 @@
|
||||
project "App_BulletExampleBrowser"
|
||||
|
||||
project "BulletExampleBrowserLib"
|
||||
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"
|
||||
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
@ -145,61 +203,4 @@ if os.is("Linux") then
|
||||
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,62 @@
|
||||
|
||||
#include "SharedMemoryInProcessPhysicsC_API.h"
|
||||
|
||||
#include "PhysicsClientSharedMemory.h"
|
||||
#include"../ExampleBrowser/InProcessExampleBrowser.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
|
||||
{
|
||||
btInProcessExampleBrowserInternalData* m_data;
|
||||
|
@ -12,6 +12,11 @@ extern "C" {
|
||||
///think more about naming. The b3ConnectPhysicsLoopback
|
||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]);
|
||||
|
||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnectMainThread(int argc, char* argv[]);
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -241,7 +241,12 @@ int main(int argc, char* argv[])
|
||||
#endif
|
||||
|
||||
#ifdef PHYSICS_IN_PROCESS_EXAMPLE_BROWSER
|
||||
|
||||
#ifdef __APPLE__
|
||||
b3PhysicsClientHandle sm = b3CreateInProcessPhysicsServerAndConnectMainThread(argc,argv);
|
||||
#else
|
||||
b3PhysicsClientHandle sm = b3CreateInProcessPhysicsServerAndConnect(argc,argv);
|
||||
#endif //__APPLE__
|
||||
#endif
|
||||
#ifdef PHYSICS_SHARED_MEMORY
|
||||
b3PhysicsClientHandle sm = b3ConnectSharedMemory(SHARED_MEMORY_KEY);
|
||||
|
Loading…
Reference in New Issue
Block a user