Switch off an optimization by default, to avoid support burden: update all objects AABBs and not just the active objects.

Call world->setForceUpdateAllAabbs( false) to re-enable the optimization: it will only update active objects (skipping static geometry)
See also http://bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=4073
This commit is contained in:
erwin.coumans
2009-09-11 19:18:37 +00:00
parent ed09140fb7
commit 49a0b479c6
2 changed files with 16 additions and 3 deletions

View File

@@ -45,7 +45,8 @@ subject to the following restrictions:
btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache, btCollisionConfiguration* collisionConfiguration) btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache, btCollisionConfiguration* collisionConfiguration)
:m_dispatcher1(dispatcher), :m_dispatcher1(dispatcher),
m_broadphasePairCache(pairCache), m_broadphasePairCache(pairCache),
m_debugDrawer(0) m_debugDrawer(0),
m_forceUpdateAllAabbs(true)
{ {
m_stackAlloc = collisionConfiguration->getStackAllocator(); m_stackAlloc = collisionConfiguration->getStackAllocator();
m_dispatchInfo.m_stackAllocator = m_stackAlloc; m_dispatchInfo.m_stackAllocator = m_stackAlloc;
@@ -164,7 +165,7 @@ void btCollisionWorld::updateAabbs()
btCollisionObject* colObj = m_collisionObjects[i]; btCollisionObject* colObj = m_collisionObjects[i];
//only update aabb of active objects //only update aabb of active objects
if (colObj->isActive()) if (m_forceUpdateAllAabbs || colObj->isActive())
{ {
updateSingleAabb(colObj); updateSingleAabb(colObj);
} }

View File

@@ -94,6 +94,9 @@ protected:
btIDebugDraw* m_debugDrawer; btIDebugDraw* m_debugDrawer;
///m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs
///it is true by default, because it is error-prone (setting the position of static objects wouldn't update their AABB)
bool m_forceUpdateAllAabbs;
public: public:
@@ -404,6 +407,15 @@ public:
return m_dispatchInfo; return m_dispatchInfo;
} }
bool getForceUpdateAllAabbs() const
{
return m_forceUpdateAllAabbs;
}
void setForceUpdateAllAabbs( bool forceUpdateAllAabbs)
{
m_forceUpdateAllAabbs = forceUpdateAllAabbs;
}
}; };