fix compile errors in non-threadsafe build
This commit is contained in:
@@ -250,6 +250,7 @@ public:
|
|||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
addTaskScheduler( btGetSequentialTaskScheduler() );
|
addTaskScheduler( btGetSequentialTaskScheduler() );
|
||||||
|
#if BT_THREADSAFE
|
||||||
addTaskScheduler( btGetOpenMPTaskScheduler() );
|
addTaskScheduler( btGetOpenMPTaskScheduler() );
|
||||||
addTaskScheduler( btGetTBBTaskScheduler() );
|
addTaskScheduler( btGetTBBTaskScheduler() );
|
||||||
addTaskScheduler( btGetPPLTaskScheduler() );
|
addTaskScheduler( btGetPPLTaskScheduler() );
|
||||||
@@ -263,6 +264,7 @@ public:
|
|||||||
btSetTaskScheduler( m_taskSchedulers[ 0 ] );
|
btSetTaskScheduler( m_taskSchedulers[ 0 ] );
|
||||||
}
|
}
|
||||||
btGetTaskScheduler()->setNumThreads( btGetTaskScheduler()->getMaxNumThreads() );
|
btGetTaskScheduler()->setNumThreads( btGetTaskScheduler()->getMaxNumThreads() );
|
||||||
|
#endif // #if BT_THREADSAFE
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTaskScheduler( btITaskScheduler* ts )
|
void addTaskScheduler( btITaskScheduler* ts )
|
||||||
@@ -353,6 +355,7 @@ static void setSolverTypeCallback(int buttonId, bool buttonState, void* userPoin
|
|||||||
|
|
||||||
static void setNumThreads( int numThreads )
|
static void setNumThreads( int numThreads )
|
||||||
{
|
{
|
||||||
|
#if BT_THREADSAFE
|
||||||
int newNumThreads = ( std::min )( numThreads, int( BT_MAX_THREAD_COUNT ) );
|
int newNumThreads = ( std::min )( numThreads, int( BT_MAX_THREAD_COUNT ) );
|
||||||
int oldNumThreads = btGetTaskScheduler()->getNumThreads();
|
int oldNumThreads = btGetTaskScheduler()->getNumThreads();
|
||||||
// only call when the thread count is different
|
// only call when the thread count is different
|
||||||
@@ -360,13 +363,16 @@ static void setNumThreads( int numThreads )
|
|||||||
{
|
{
|
||||||
btGetTaskScheduler()->setNumThreads( newNumThreads );
|
btGetTaskScheduler()->setNumThreads( newNumThreads );
|
||||||
}
|
}
|
||||||
|
#endif // #if BT_THREADSAFE
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apiSelectButtonCallback(int buttonId, bool buttonState, void* userPointer)
|
static void apiSelectButtonCallback(int buttonId, bool buttonState, void* userPointer)
|
||||||
{
|
{
|
||||||
|
#if BT_THREADSAFE
|
||||||
// change the task scheduler
|
// change the task scheduler
|
||||||
btSetTaskScheduler( gTaskSchedulerMgr.getTaskScheduler( buttonId ) );
|
btSetTaskScheduler( gTaskSchedulerMgr.getTaskScheduler( buttonId ) );
|
||||||
setNumThreads( int( gSliderNumThreads ) );
|
setNumThreads( int( gSliderNumThreads ) );
|
||||||
|
#endif // #if BT_THREADSAFE
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setThreadCountCallback(float val, void* userPtr)
|
static void setThreadCountCallback(float val, void* userPtr)
|
||||||
@@ -392,6 +398,7 @@ void CommonRigidBodyMTBase::createEmptyDynamicsWorld()
|
|||||||
#endif
|
#endif
|
||||||
if ( gMultithreadedWorld )
|
if ( gMultithreadedWorld )
|
||||||
{
|
{
|
||||||
|
#if BT_THREADSAFE
|
||||||
m_dispatcher = NULL;
|
m_dispatcher = NULL;
|
||||||
btDefaultCollisionConstructionInfo cci;
|
btDefaultCollisionConstructionInfo cci;
|
||||||
cci.m_defaultMaxPersistentManifoldPoolSize = 80000;
|
cci.m_defaultMaxPersistentManifoldPoolSize = 80000;
|
||||||
@@ -416,6 +423,7 @@ void CommonRigidBodyMTBase::createEmptyDynamicsWorld()
|
|||||||
m_dynamicsWorld = world;
|
m_dynamicsWorld = world;
|
||||||
m_multithreadedWorld = true;
|
m_multithreadedWorld = true;
|
||||||
btAssert( btGetTaskScheduler() != NULL );
|
btAssert( btGetTaskScheduler() != NULL );
|
||||||
|
#endif // #if BT_THREADSAFE
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -534,6 +542,7 @@ void CommonRigidBodyMTBase::createDefaultParameters()
|
|||||||
}
|
}
|
||||||
if (m_multithreadedWorld)
|
if (m_multithreadedWorld)
|
||||||
{
|
{
|
||||||
|
#if BT_THREADSAFE
|
||||||
// create a button for each supported threading API
|
// create a button for each supported threading API
|
||||||
for ( int iApi = 0; iApi < gTaskSchedulerMgr.getNumTaskSchedulers(); ++iApi )
|
for ( int iApi = 0; iApi < gTaskSchedulerMgr.getNumTaskSchedulers(); ++iApi )
|
||||||
{
|
{
|
||||||
@@ -558,6 +567,7 @@ void CommonRigidBodyMTBase::createDefaultParameters()
|
|||||||
slider.m_clampToIntegers = true;
|
slider.m_clampToIntegers = true;
|
||||||
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
|
||||||
}
|
}
|
||||||
|
#endif // #if BT_THREADSAFE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,6 +599,7 @@ void CommonRigidBodyMTBase::drawScreenText()
|
|||||||
{
|
{
|
||||||
if ( m_multithreadedWorld )
|
if ( m_multithreadedWorld )
|
||||||
{
|
{
|
||||||
|
#if BT_THREADSAFE
|
||||||
int numManifolds = m_dispatcher->getNumManifolds();
|
int numManifolds = m_dispatcher->getNumManifolds();
|
||||||
int numContacts = 0;
|
int numContacts = 0;
|
||||||
for ( int i = 0; i < numManifolds; ++i )
|
for ( int i = 0; i < numManifolds; ++i )
|
||||||
@@ -607,6 +618,7 @@ void CommonRigidBodyMTBase::drawScreenText()
|
|||||||
);
|
);
|
||||||
m_guiHelper->getAppInterface()->drawText( msg, 100, yCoord, 0.4f );
|
m_guiHelper->getAppInterface()->drawText( msg, 100, yCoord, 0.4f );
|
||||||
yCoord += yStep;
|
yCoord += yStep;
|
||||||
|
#endif // #if BT_THREADSAFE
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int sm = gSolverMode;
|
int sm = gSolverMode;
|
||||||
|
|||||||
@@ -114,7 +114,10 @@ struct InplaceSolverIslandCallbackMt : public btSimulationIslandManagerMt::Islan
|
|||||||
|
|
||||||
btConstraintSolverPoolMt::ThreadSolver* btConstraintSolverPoolMt::getAndLockThreadSolver()
|
btConstraintSolverPoolMt::ThreadSolver* btConstraintSolverPoolMt::getAndLockThreadSolver()
|
||||||
{
|
{
|
||||||
int i = btGetCurrentThreadIndex() % m_solvers.size();
|
int i = 0;
|
||||||
|
#if BT_THREADSAFE
|
||||||
|
i = btGetCurrentThreadIndex() % m_solvers.size();
|
||||||
|
#endif // #if BT_THREADSAFE
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
ThreadSolver& solver = m_solvers[ i ];
|
ThreadSolver& solver = m_solvers[ i ];
|
||||||
|
|||||||
@@ -465,6 +465,12 @@ bool btSpinMutex::tryLock()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// non-parallel version of btParallelFor
|
||||||
|
void btParallelFor( int iBegin, int iEnd, int grainSize, const btIParallelForBody& body )
|
||||||
|
{
|
||||||
|
btAssert(!"called btParallelFor in non-threadsafe build. enable BT_THREADSAFE");
|
||||||
|
body.forLoop( iBegin, iEnd );
|
||||||
|
}
|
||||||
|
|
||||||
#endif // #if BT_THREADSAFE
|
#endif // #if BT_THREADSAFE
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user