Merge pull request #753 from YunfeiBai/master

Add micro sleep to fix slowness problem in VR.
This commit is contained in:
erwincoumans 2016-08-22 17:20:46 -04:00 committed by GitHub
commit db66b06640
4 changed files with 17 additions and 5 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -79,4 +79,3 @@ 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})