Refactoring to enable multi SAP broadphase.
This was already planned, and Pierre Terdiman recent thread motivated me to decouple the paircache from the sweep and prune. http://continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
This commit is contained in:
@@ -74,9 +74,10 @@ void btAxisSweep3::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,con
|
||||
|
||||
|
||||
btAxisSweep3::btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles)
|
||||
:btOverlappingPairCache()
|
||||
:m_invalidPair(0)
|
||||
{
|
||||
m_invalidPair = 0;
|
||||
m_pairCache = new btOverlappingPairCache();
|
||||
|
||||
//assert(bounds.HasVolume());
|
||||
|
||||
// 1 handle is reserved as sentinel
|
||||
@@ -244,7 +245,7 @@ void btAxisSweep3::removeHandle(BP_FP_INT_TYPE handle)
|
||||
//explicitly remove the pairs containing the proxy
|
||||
//we could do it also in the sortMinUp (passing true)
|
||||
//todo: compare performance
|
||||
removeOverlappingPairsContainingProxy(pHandle);
|
||||
m_pairCache->removeOverlappingPairsContainingProxy(pHandle);
|
||||
|
||||
|
||||
// compute current limit of edge arrays
|
||||
@@ -293,27 +294,16 @@ void btAxisSweep3::removeHandle(BP_FP_INT_TYPE handle)
|
||||
extern int gOverlappingPairs;
|
||||
|
||||
|
||||
void btAxisSweep3::refreshOverlappingPairs()
|
||||
{
|
||||
|
||||
}
|
||||
void btAxisSweep3::processAllOverlappingPairs(btOverlapCallback* callback)
|
||||
void btAxisSweep3::calculateOverlappingPairs()
|
||||
{
|
||||
|
||||
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
||||
|
||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||
m_overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
||||
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
||||
|
||||
//remove the 'invalid' ones
|
||||
#ifdef USE_POPBACK_REMOVAL
|
||||
while (m_invalidPair>0)
|
||||
{
|
||||
m_invalidPair--;
|
||||
m_overlappingPairArray.pop_back();
|
||||
}
|
||||
#else
|
||||
m_overlappingPairArray.resize(m_overlappingPairArray.size() - m_invalidPair);
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
#endif
|
||||
|
||||
|
||||
int i;
|
||||
@@ -324,10 +314,10 @@ void btAxisSweep3::processAllOverlappingPairs(btOverlapCallback* callback)
|
||||
previousPair.m_algorithm = 0;
|
||||
|
||||
|
||||
for (i=0;i<m_overlappingPairArray.size();i++)
|
||||
for (i=0;i<overlappingPairArray.size();i++)
|
||||
{
|
||||
|
||||
btBroadphasePair& pair = m_overlappingPairArray[i];
|
||||
btBroadphasePair& pair = overlappingPairArray[i];
|
||||
|
||||
bool isDuplicate = (pair == previousPair);
|
||||
|
||||
@@ -337,11 +327,11 @@ void btAxisSweep3::processAllOverlappingPairs(btOverlapCallback* callback)
|
||||
|
||||
if (!isDuplicate)
|
||||
{
|
||||
bool hasOverlap = testOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
||||
|
||||
if (hasOverlap)
|
||||
{
|
||||
needsRemoval = callback->processOverlap(pair);
|
||||
needsRemoval = false;//callback->processOverlap(pair);
|
||||
} else
|
||||
{
|
||||
needsRemoval = true;
|
||||
@@ -356,7 +346,7 @@ void btAxisSweep3::processAllOverlappingPairs(btOverlapCallback* callback)
|
||||
|
||||
if (needsRemoval)
|
||||
{
|
||||
cleanOverlappingPair(pair);
|
||||
m_pairCache->cleanOverlappingPair(pair);
|
||||
|
||||
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||
// m_overlappingPairArray.pop_back();
|
||||
@@ -367,10 +357,24 @@ void btAxisSweep3::processAllOverlappingPairs(btOverlapCallback* callback)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||
#define CLEAN_INVALID_PAIRS 1
|
||||
#ifdef CLEAN_INVALID_PAIRS
|
||||
|
||||
//perform a sort, to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
#endif//CLEAN_INVALID_PAIRS
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool btAxisSweep3::testOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
|
||||
bool btAxisSweep3::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
const Handle* pHandleA = static_cast<Handle*>(proxy0);
|
||||
const Handle* pHandleB = static_cast<Handle*>(proxy1);
|
||||
@@ -485,7 +489,7 @@ void btAxisSweep3::sortMinDown(int axis, BP_FP_INT_TYPE edge, bool updateOverlap
|
||||
// if previous edge is a maximum check the bounds and add an overlap if necessary
|
||||
if (updateOverlaps && testOverlap(axis,pHandleEdge, pHandlePrev))
|
||||
{
|
||||
addOverlappingPair(pHandleEdge,pHandlePrev);
|
||||
m_pairCache->addOverlappingPair(pHandleEdge,pHandlePrev);
|
||||
|
||||
//AddOverlap(pEdge->m_handle, pPrev->m_handle);
|
||||
|
||||
@@ -636,7 +640,7 @@ void btAxisSweep3::sortMaxUp(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps)
|
||||
{
|
||||
Handle* handle0 = getHandle(pEdge->m_handle);
|
||||
Handle* handle1 = getHandle(pNext->m_handle);
|
||||
addOverlappingPair(handle0,handle1);
|
||||
m_pairCache->addOverlappingPair(handle0,handle1);
|
||||
}
|
||||
|
||||
// update edge reference in other handle
|
||||
@@ -658,3 +662,5 @@ void btAxisSweep3::sortMaxUp(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "LinearMath/btPoint3.h"
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "btOverlappingPairCache.h"
|
||||
#include "btBroadphaseInterface.h"
|
||||
#include "btBroadphaseProxy.h"
|
||||
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
/// btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase.
|
||||
/// It uses arrays rather then lists for storage of the 3 axis. Also it operates using integer coordinates instead of floats.
|
||||
/// The testOverlap check is optimized to check the array index, rather then the actual AABB coordinates/pos
|
||||
class btAxisSweep3 : public btOverlappingPairCache
|
||||
class btAxisSweep3 : public btBroadphaseInterface
|
||||
{
|
||||
|
||||
public:
|
||||
@@ -77,7 +78,7 @@ public:
|
||||
}; // 24 bytes + 24 for Edge structures = 44 bytes total per entry
|
||||
|
||||
|
||||
private:
|
||||
protected:
|
||||
btPoint3 m_worldAabbMin; // overall system bounds
|
||||
btPoint3 m_worldAabbMax; // overall system bounds
|
||||
|
||||
@@ -90,7 +91,9 @@ private:
|
||||
|
||||
Edge* m_pEdges[3]; // edge arrays for the 3 axes (each array has m_maxHandles * 2 + 2 sentinel entries)
|
||||
|
||||
int m_invalidPair;
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
|
||||
int m_invalidPair;
|
||||
|
||||
// allocation/deallocation
|
||||
BP_FP_INT_TYPE allocHandle();
|
||||
@@ -117,7 +120,7 @@ public:
|
||||
btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles = 16384);
|
||||
virtual ~btAxisSweep3();
|
||||
|
||||
virtual void refreshOverlappingPairs();
|
||||
virtual void calculateOverlappingPairs();
|
||||
|
||||
BP_FP_INT_TYPE addHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
void removeHandle(BP_FP_INT_TYPE handle);
|
||||
@@ -130,7 +133,18 @@ public:
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);
|
||||
bool testOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
btOverlappingPairCache* getOverlappingPairCache()
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
const btOverlappingPairCache* getOverlappingPairCache() const
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ subject to the following restrictions:
|
||||
|
||||
struct btDispatcherInfo;
|
||||
class btDispatcher;
|
||||
struct btBroadphaseProxy;
|
||||
#include "btBroadphaseProxy.h"
|
||||
class btOverlappingPairCache;
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
|
||||
///BroadphaseInterface for aabb-overlapping object pairs
|
||||
@@ -32,8 +34,12 @@ public:
|
||||
virtual btBroadphaseProxy* createProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0;
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy)=0;
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)=0;
|
||||
virtual void cleanProxyFromPairs(btBroadphaseProxy* proxy)=0;
|
||||
|
||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||
virtual void calculateOverlappingPairs()=0;
|
||||
|
||||
virtual btOverlappingPairCache* getOverlappingPairCache()=0;
|
||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const =0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -182,6 +182,7 @@ SIMD_FORCE_INLINE bool operator<(const btBroadphasePair& a, const btBroadphasePa
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class btBroadphasePairSortPredicate
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -194,3 +194,6 @@ void btOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callb
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -40,19 +40,22 @@ struct btOverlapFilterCallback
|
||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const = 0;
|
||||
};
|
||||
|
||||
typedef btAlignedObjectArray<btBroadphasePair> btBroadphasePairArray;
|
||||
|
||||
///btOverlappingPairCache maintains the objects with overlapping AABB
|
||||
///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase
|
||||
class btOverlappingPairCache : public btBroadphaseInterface
|
||||
class btOverlappingPairCache
|
||||
{
|
||||
protected:
|
||||
//avoid brute-force finding all the time
|
||||
btAlignedObjectArray<btBroadphasePair> m_overlappingPairArray;
|
||||
btBroadphasePairArray m_overlappingPairArray;
|
||||
|
||||
//during the dispatch, check that user doesn't destroy/create proxy
|
||||
bool m_blockedForChanges;
|
||||
|
||||
//if set, use the callback instead of the built in filter in needBroadphaseCollision
|
||||
btOverlapFilterCallback* m_overlapFilterCallback;
|
||||
|
||||
public:
|
||||
|
||||
btOverlappingPairCache();
|
||||
@@ -84,10 +87,16 @@ class btOverlappingPairCache : public btBroadphaseInterface
|
||||
|
||||
return collides;
|
||||
}
|
||||
|
||||
|
||||
btBroadphasePairArray& getOverlappingPairArray()
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
virtual void refreshOverlappingPairs() =0;
|
||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||
{
|
||||
return m_overlappingPairArray;
|
||||
}
|
||||
|
||||
btBroadphasePair* getOverlappingPairArrayPtr()
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ subject to the following restrictions:
|
||||
#include "LinearMath/btMatrix3x3.h"
|
||||
#include <new>
|
||||
|
||||
extern int gOverlappingPairs;
|
||||
|
||||
void btSimpleBroadphase::validate()
|
||||
{
|
||||
@@ -36,11 +37,14 @@ void btSimpleBroadphase::validate()
|
||||
}
|
||||
|
||||
btSimpleBroadphase::btSimpleBroadphase(int maxProxies)
|
||||
:btOverlappingPairCache(),
|
||||
:
|
||||
m_firstFreeProxy(0),
|
||||
m_numProxies(0),
|
||||
m_maxProxies(maxProxies)
|
||||
m_maxProxies(maxProxies),
|
||||
m_invalidPair(0)
|
||||
{
|
||||
|
||||
m_pairCache = new btOverlappingPairCache();
|
||||
|
||||
m_proxies = new btSimpleBroadphaseProxy[maxProxies];
|
||||
m_freeProxies = new int[maxProxies];
|
||||
@@ -136,7 +140,7 @@ void btSimpleBroadphase::destroyProxy(btBroadphaseProxy* proxyOrg)
|
||||
btAssert (index < m_maxProxies);
|
||||
m_freeProxies[--m_firstFreeProxy] = index;
|
||||
|
||||
removeOverlappingPairsContainingProxy(proxyOrg);
|
||||
m_pairCache->removeOverlappingPairsContainingProxy(proxyOrg);
|
||||
|
||||
for (i=0;i<m_numProxies;i++)
|
||||
{
|
||||
@@ -186,7 +190,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void btSimpleBroadphase::refreshOverlappingPairs()
|
||||
void btSimpleBroadphase::calculateOverlappingPairs()
|
||||
{
|
||||
//first check for new overlapping pairs
|
||||
int i,j;
|
||||
@@ -202,21 +206,95 @@ void btSimpleBroadphase::refreshOverlappingPairs()
|
||||
|
||||
if (aabbOverlap(p0,p1))
|
||||
{
|
||||
if ( !findPair(proxy0,proxy1))
|
||||
if ( !m_pairCache->findPair(proxy0,proxy1))
|
||||
{
|
||||
addOverlappingPair(proxy0,proxy1);
|
||||
m_pairCache->addOverlappingPair(proxy0,proxy1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
|
||||
|
||||
CheckOverlapCallback checkOverlap;
|
||||
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
||||
|
||||
processAllOverlappingPairs(&checkOverlap);
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
|
||||
|
||||
btBroadphasePair previousPair;
|
||||
previousPair.m_pProxy0 = 0;
|
||||
previousPair.m_pProxy1 = 0;
|
||||
previousPair.m_algorithm = 0;
|
||||
|
||||
|
||||
for (i=0;i<overlappingPairArray.size();i++)
|
||||
{
|
||||
|
||||
btBroadphasePair& pair = overlappingPairArray[i];
|
||||
|
||||
bool isDuplicate = (pair == previousPair);
|
||||
|
||||
previousPair = pair;
|
||||
|
||||
bool needsRemoval = false;
|
||||
|
||||
if (!isDuplicate)
|
||||
{
|
||||
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
|
||||
|
||||
if (hasOverlap)
|
||||
{
|
||||
needsRemoval = false;//callback->processOverlap(pair);
|
||||
} else
|
||||
{
|
||||
needsRemoval = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
//remove duplicate
|
||||
needsRemoval = true;
|
||||
//should have no algorithm
|
||||
btAssert(!pair.m_algorithm);
|
||||
}
|
||||
|
||||
if (needsRemoval)
|
||||
{
|
||||
m_pairCache->cleanOverlappingPair(pair);
|
||||
|
||||
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
|
||||
// m_overlappingPairArray.pop_back();
|
||||
pair.m_pProxy0 = 0;
|
||||
pair.m_pProxy1 = 0;
|
||||
m_invalidPair++;
|
||||
gOverlappingPairs--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///if you don't like to skip the invalid pairs in the array, execute following code:
|
||||
#define CLEAN_INVALID_PAIRS 1
|
||||
#ifdef CLEAN_INVALID_PAIRS
|
||||
|
||||
//perform a sort, to sort 'invalid' pairs to the end
|
||||
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
|
||||
|
||||
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
|
||||
m_invalidPair = 0;
|
||||
#endif//CLEAN_INVALID_PAIRS
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool btSimpleBroadphase::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
|
||||
{
|
||||
btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0);
|
||||
btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1);
|
||||
return aabbOverlap(p0,p1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ struct btSimpleBroadphaseProxy : public btBroadphaseProxy
|
||||
};
|
||||
|
||||
///SimpleBroadphase is a brute force aabb culling broadphase based on O(n^2) aabb checks
|
||||
class btSimpleBroadphase : public btOverlappingPairCache
|
||||
class btSimpleBroadphase : public btBroadphaseInterface
|
||||
{
|
||||
|
||||
protected:
|
||||
@@ -50,7 +50,9 @@ protected:
|
||||
btSimpleBroadphaseProxy** m_pProxies;
|
||||
int m_numProxies;
|
||||
|
||||
btOverlappingPairCache* m_pairCache;
|
||||
|
||||
int m_invalidPair;
|
||||
|
||||
int m_maxProxies;
|
||||
|
||||
@@ -67,7 +69,8 @@ protected:
|
||||
protected:
|
||||
|
||||
|
||||
virtual void refreshOverlappingPairs();
|
||||
virtual void calculateOverlappingPairs();
|
||||
|
||||
public:
|
||||
btSimpleBroadphase(int maxProxies=16384);
|
||||
virtual ~btSimpleBroadphase();
|
||||
@@ -82,9 +85,16 @@ public:
|
||||
virtual void destroyProxy(btBroadphaseProxy* proxy);
|
||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);
|
||||
|
||||
|
||||
|
||||
btOverlappingPairCache* getOverlappingPairCache()
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
const btOverlappingPairCache* getOverlappingPairCache() const
|
||||
{
|
||||
return m_pairCache;
|
||||
}
|
||||
|
||||
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -37,7 +37,8 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h"
|
||||
|
||||
|
||||
btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache, int stackSize)
|
||||
|
||||
btCollisionWorld::btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache, int stackSize)
|
||||
:m_dispatcher1(dispatcher),
|
||||
m_broadphasePairCache(pairCache),
|
||||
m_ownsDispatcher(false),
|
||||
@@ -65,7 +66,7 @@ btCollisionWorld::~btCollisionWorld()
|
||||
//
|
||||
// only clear the cached algorithms
|
||||
//
|
||||
getBroadphase()->cleanProxyFromPairs(bp);
|
||||
getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp);
|
||||
getBroadphase()->destroyProxy(bp);
|
||||
}
|
||||
}
|
||||
@@ -136,8 +137,7 @@ void btCollisionWorld::performDiscreteCollisionDetection()
|
||||
m_broadphasePairCache->setAabb(m_collisionObjects[i]->getBroadphaseHandle(),aabbMin,aabbMax);
|
||||
}
|
||||
|
||||
m_broadphasePairCache->refreshOverlappingPairs();
|
||||
|
||||
m_broadphasePairCache->calculateOverlappingPairs();
|
||||
|
||||
END_PROFILE("perform Broadphase Collision Detection");
|
||||
|
||||
@@ -145,7 +145,7 @@ void btCollisionWorld::performDiscreteCollisionDetection()
|
||||
|
||||
btDispatcher* dispatcher = getDispatcher();
|
||||
if (dispatcher)
|
||||
dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache,dispatchInfo);
|
||||
dispatcher->dispatchAllCollisionPairs(m_broadphasePairCache->getOverlappingPairCache(),dispatchInfo);
|
||||
|
||||
END_PROFILE("performDiscreteCollisionDetection");
|
||||
|
||||
@@ -166,7 +166,7 @@ void btCollisionWorld::removeCollisionObject(btCollisionObject* collisionObject)
|
||||
//
|
||||
// only clear the cached algorithms
|
||||
//
|
||||
getBroadphase()->cleanProxyFromPairs(bp);
|
||||
getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bp);
|
||||
getBroadphase()->destroyProxy(bp);
|
||||
collisionObject->setBroadphaseHandle(0);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ protected:
|
||||
|
||||
btStackAlloc* m_stackAlloc;
|
||||
|
||||
btOverlappingPairCache* m_broadphasePairCache;
|
||||
btBroadphaseInterface* m_broadphasePairCache;
|
||||
|
||||
bool m_ownsDispatcher;
|
||||
bool m_ownsBroadphasePairCache;
|
||||
@@ -98,7 +98,7 @@ protected:
|
||||
public:
|
||||
|
||||
//this constructor doesn't own the dispatcher and paircache/broadphase
|
||||
btCollisionWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache, int stackSize = 2*1024*1024);
|
||||
btCollisionWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphasePairCache, int stackSize = 2*1024*1024);
|
||||
|
||||
virtual ~btCollisionWorld();
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
|
||||
btOverlappingPairCache* getPairCache()
|
||||
{
|
||||
return m_broadphasePairCache;
|
||||
return m_broadphasePairCache->getOverlappingPairCache();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ plDynamicsWorldHandle plCreateDynamicsWorld(plPhysicsSdkHandle physicsSdkHandle)
|
||||
{
|
||||
btPhysicsSdk* physicsSdk = reinterpret_cast<btPhysicsSdk*>(physicsSdkHandle);
|
||||
btDispatcher* dispatcher = new btCollisionDispatcher();
|
||||
btOverlappingPairCache* pairCache = new btAxisSweep3(physicsSdk->m_worldAabbMin,physicsSdk->m_worldAabbMax);
|
||||
btBroadphaseInterface* pairCache = new btAxisSweep3(physicsSdk->m_worldAabbMin,physicsSdk->m_worldAabbMax);
|
||||
btConstraintSolver* constraintSolver = new btSequentialImpulseConstraintSolver();
|
||||
|
||||
return (plDynamicsWorldHandle) new btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver);
|
||||
|
||||
@@ -57,7 +57,7 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
|
||||
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
|
||||
btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver)
|
||||
:btDynamicsWorld(dispatcher,pairCache),
|
||||
m_constraintSolver(constraintSolver? constraintSolver: new btSequentialImpulseConstraintSolver),
|
||||
m_debugDrawer(0),
|
||||
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
|
||||
|
||||
///this btDiscreteDynamicsWorld constructor gets created objects from the user, and will not delete those
|
||||
btDiscreteDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver);
|
||||
btDiscreteDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver);
|
||||
|
||||
virtual ~btDiscreteDynamicsWorld();
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ class btDynamicsWorld : public btCollisionWorld
|
||||
public:
|
||||
|
||||
|
||||
btDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache)
|
||||
:btCollisionWorld(dispatcher,pairCache)
|
||||
btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase)
|
||||
:btCollisionWorld(dispatcher,broadphase)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ extern "C" void btBulletDynamicsProbe () {}
|
||||
|
||||
|
||||
|
||||
btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver)
|
||||
btSimpleDynamicsWorld::btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver)
|
||||
:btDynamicsWorld(dispatcher,pairCache),
|
||||
m_constraintSolver(constraintSolver),
|
||||
m_ownsConstraintSolver(false),
|
||||
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
|
||||
|
||||
///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
|
||||
btSimpleDynamicsWorld(btDispatcher* dispatcher,btOverlappingPairCache* pairCache,btConstraintSolver* constraintSolver);
|
||||
btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver);
|
||||
|
||||
virtual ~btSimpleDynamicsWorld();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user