From d26c424e11afca99b820198d323591f8a8453178 Mon Sep 17 00:00:00 2001 From: YunfeiBai Date: Fri, 19 Aug 2016 12:00:55 -0700 Subject: [PATCH 1/3] modify cmake for pybullet --- examples/pybullet/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/pybullet/CMakeLists.txt b/examples/pybullet/CMakeLists.txt index 5540d10de..0d983ac70 100644 --- a/examples/pybullet/CMakeLists.txt +++ b/examples/pybullet/CMakeLists.txt @@ -74,9 +74,6 @@ ENDIF(WIN32) ADD_LIBRARY(pybullet SHARED ${pybullet_SRCS}) -SET_TARGET_PROPERTIES(pybullet PROPERTIES VERSION ${BULLET_VERSION}) -SET_TARGET_PROPERTIES(pybullet PROPERTIES SOVERSION ${BULLET_VERSION}) - TARGET_LINK_LIBRARIES(pybullet BulletExampleBrowserLib BulletFileLoader BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath OpenGLWindow gwen Bullet3Common ${PYTHON_LIBRARIES}) From 6751648bce2d26d6234a7a2e4a598cb97bb208b9 Mon Sep 17 00:00:00 2001 From: YunfeiBai Date: Fri, 19 Aug 2016 13:58:53 -0700 Subject: [PATCH 2/3] add some micro-sleep to prevent 100% CPU/memory bus hogging, preventing the graphics thread from making progress. debug draw color black for contact normal move debug draw option for constraint frames into 'k' key. --- examples/ExampleBrowser/OpenGLExampleBrowser.cpp | 6 +++++- examples/ExampleBrowser/OpenGLGuiHelper.cpp | 4 ++-- examples/SharedMemory/PhysicsServerExample.cpp | 11 ++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp index be280c877..97cec90d6 100644 --- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp +++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp @@ -194,7 +194,6 @@ void MyKeyboardCallback(int key, int state) } if (key=='c' && state) { - gDebugDrawFlags ^= btIDebugDraw::DBG_DrawConstraints; gDebugDrawFlags ^= btIDebugDraw::DBG_DrawContactPoints; } if (key == 'd' && state) @@ -202,6 +201,11 @@ void MyKeyboardCallback(int key, int state) gDebugDrawFlags ^= btIDebugDraw::DBG_NoDeactivation; gDisableDeactivation = ((gDebugDrawFlags & btIDebugDraw::DBG_NoDeactivation) != 0); } + if (key == 'k' && state) + { + gDebugDrawFlags ^= btIDebugDraw::DBG_DrawConstraints; + } + if (key=='l' && state) { gDebugDrawFlags ^= btIDebugDraw::DBG_DrawConstraintLimits; diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.cpp b/examples/ExampleBrowser/OpenGLGuiHelper.cpp index e49369547..8001b11e3 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.cpp +++ b/examples/ExampleBrowser/OpenGLGuiHelper.cpp @@ -85,8 +85,8 @@ public: virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color) { drawLine(PointOnB,PointOnB+normalOnB*distance,color); - btVector3 red(0.3, 1., 0.3); - drawLine(PointOnB, PointOnB + normalOnB*0.01, red); + btVector3 ncolor(0, 0, 0); + drawLine(PointOnB, PointOnB + normalOnB*0.01, ncolor); } diff --git a/examples/SharedMemory/PhysicsServerExample.cpp b/examples/SharedMemory/PhysicsServerExample.cpp index 489d9526f..0ff5b4f93 100644 --- a/examples/SharedMemory/PhysicsServerExample.cpp +++ b/examples/SharedMemory/PhysicsServerExample.cpp @@ -130,13 +130,15 @@ void MotionThreadFunc(void* userPtr,void* lsMemory) do { //todo(erwincoumans): do we want some sleep to reduce CPU resources in this thread? + double deltaTimeInSeconds = double(clock.getTimeMicroseconds())/1000000.; + if (deltaTimeInSeconds<(1./5000.)) { + skip++; skip1++; - if (0==(skip1&0x3)) { b3Clock::usleep(250); } @@ -281,6 +283,7 @@ public: m_cs->unlock(); while (m_cs->getSharedParam(1)!=eGUIHelperIdle) { + b3Clock::usleep(1000); } } @@ -294,6 +297,7 @@ public: m_cs->unlock(); while (m_cs->getSharedParam(1)!=eGUIHelperIdle) { + b3Clock::usleep(1000); } } @@ -326,6 +330,7 @@ public: m_cs->unlock(); while (m_cs->getSharedParam(1)!=eGUIHelperIdle) { + b3Clock::usleep(1000); } return m_textureId; } @@ -343,6 +348,7 @@ public: m_cs->unlock(); while (m_cs->getSharedParam(1)!=eGUIHelperIdle) { + b3Clock::usleep(1000); } return m_shapeIndex; } @@ -359,6 +365,7 @@ public: m_cs->unlock(); while (m_cs->getSharedParam(1)!=eGUIHelperIdle) { + b3Clock::usleep(1000); } return m_instanceId; } @@ -370,6 +377,7 @@ public: m_cs->unlock(); while (m_cs->getSharedParam(1)!=eGUIHelperIdle) { + b3Clock::usleep(1000); } } @@ -444,6 +452,7 @@ public: m_cs->unlock(); while (m_cs->getSharedParam(1)!=eGUIHelperIdle) { + b3Clock::usleep(1000); } } From 8eccac6fd819a9860ae7c7986cb5e38b25dab7f3 Mon Sep 17 00:00:00 2001 From: yunfeibai Date: Mon, 22 Aug 2016 10:26:56 -0700 Subject: [PATCH 3/3] Update CMakeLists to be the same as upstream. --- examples/pybullet/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/pybullet/CMakeLists.txt b/examples/pybullet/CMakeLists.txt index e58cabb58..a5afa5d66 100644 --- a/examples/pybullet/CMakeLists.txt +++ b/examples/pybullet/CMakeLists.txt @@ -73,7 +73,9 @@ ENDIF(WIN32) ADD_LIBRARY(pybullet SHARED ${pybullet_SRCS}) +SET_TARGET_PROPERTIES(pybullet PROPERTIES VERSION ${BULLET_VERSION}) +SET_TARGET_PROPERTIES(pybullet PROPERTIES SOVERSION ${BULLET_VERSION}) + TARGET_LINK_LIBRARIES(pybullet BulletExampleBrowserLib BulletFileLoader BulletWorldImporter BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath OpenGLWindow gwen Bullet3Common ${PYTHON_LIBRARIES}) -