From 44186898af2e7ef8140d37475b8592e783d97685 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Sat, 15 Mar 2008 08:59:26 +0000 Subject: [PATCH] Got btMultiSapBroadphase in a working state. Now tuning/optimizations can be started. Added getBroadphaseAabb to btBroadphaseInterface. --- .../BroadphaseCollision/btAxisSweep3.h | 20 +- .../btBroadphaseInterface.h | 4 + .../btMultiSapBroadphase.cpp | 289 ++++++++++++++++-- .../btMultiSapBroadphase.h | 46 ++- .../BroadphaseCollision/btSimpleBroadphase.h | 7 + 5 files changed, 316 insertions(+), 50 deletions(-) diff --git a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h index 494a37966..a2cf4062d 100644 --- a/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h +++ b/src/BulletCollision/BroadphaseCollision/btAxisSweep3.h @@ -151,6 +151,16 @@ public: { return m_userPairCallback; } + + ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame + ///will add some transform later + virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const + { + aabbMin = m_worldAabbMin; + aabbMax = m_worldAabbMax; + } + + }; //////////////////////////////////////////////////////////////////// @@ -216,7 +226,7 @@ void btAxisSweep3Internal::setAabb(btBroadphaseProxy* proxy,cons template -btAxisSweep3Internal::btAxisSweep3Internal(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel,BP_FP_INT_TYPE maxHandles, btOverlappingPairCache* pairCache ) +btAxisSweep3Internal::btAxisSweep3Internal(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, BP_FP_INT_TYPE handleMask, BP_FP_INT_TYPE handleSentinel,BP_FP_INT_TYPE userMaxHandles, btOverlappingPairCache* pairCache ) :m_bpHandleMask(handleMask), m_handleSentinel(handleSentinel), m_pairCache(pairCache), @@ -224,6 +234,8 @@ m_userPairCallback(0), m_ownsPairCache(false), m_invalidPair(0) { + BP_FP_INT_TYPE maxHandles = userMaxHandles+1;//need to add one sentinel handle + if (!m_pairCache) { void* ptr = btAlignedAlloc(sizeof(btHashedOverlappingPairCache),16); @@ -411,8 +423,10 @@ void btAxisSweep3Internal::removeHandle(BP_FP_INT_TYPE handle,bt //explicitly remove the pairs containing the proxy //we could do it also in the sortMinUp (passing true) //todo: compare performance - m_pairCache->removeOverlappingPairsContainingProxy(pHandle,dispatcher); - + if (!m_pairCache->hasDeferredRemoval()) + { + m_pairCache->removeOverlappingPairsContainingProxy(pHandle,dispatcher); + } // compute current limit of edge arrays int limit = m_numHandles * 2; diff --git a/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h b/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h index 97ba20743..cf320ec23 100644 --- a/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h +++ b/src/BulletCollision/BroadphaseCollision/btBroadphaseInterface.h @@ -41,6 +41,10 @@ public: virtual btOverlappingPairCache* getOverlappingPairCache()=0; virtual const btOverlappingPairCache* getOverlappingPairCache() const =0; + ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame + ///will add some transform later + virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const =0; + }; #endif //BROADPHASE_INTERFACE_H diff --git a/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp b/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp index fa96e19cc..893f3aebc 100644 --- a/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp +++ b/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.cpp @@ -17,16 +17,31 @@ subject to the following restrictions: #include "btSimpleBroadphase.h" #include "LinearMath/btAabbUtil2.h" +#include "BulletCollision/CollisionShapes/btOptimizedBvh.h" /// btSapBroadphaseArray m_sapBroadphases; /// btOverlappingPairCache* m_overlappingPairs; extern int gOverlappingPairs; +/* +class btMultiSapSortedOverlappingPairCache : public btSortedOverlappingPairCache +{ +public: + + virtual btBroadphasePair* addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) + { + return btSortedOverlappingPairCache::addOverlappingPair((btBroadphaseProxy*)proxy0->m_multiSapParentProxy,(btBroadphaseProxy*)proxy1->m_multiSapParentProxy); + } +}; + +*/ + btMultiSapBroadphase::btMultiSapBroadphase(int maxProxies,btOverlappingPairCache* pairCache) :m_overlappingPairs(pairCache), m_ownsPairCache(false), -m_invalidPair(0) +m_invalidPair(0), +m_optimizedAabbTree(0) { if (!m_overlappingPairs) { @@ -42,11 +57,9 @@ m_invalidPair(0) // return true when pairs need collision virtual bool needBroadphaseCollision(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1) const { - btMultiSapBroadphase::btMultiSapProxy* multiSapProxy0 = (btMultiSapBroadphase::btMultiSapProxy*)childProxy0->m_multiSapParentProxy; - btMultiSapBroadphase::btMultiSapProxy* multiSapProxy1 = (btMultiSapBroadphase::btMultiSapProxy*)childProxy1->m_multiSapParentProxy; - bool collides = (multiSapProxy0->m_collisionFilterGroup & multiSapProxy1->m_collisionFilterMask) != 0; - collides = collides && (multiSapProxy1->m_collisionFilterGroup & multiSapProxy0->m_collisionFilterMask); + bool collides = (childProxy0->m_collisionFilterGroup & childProxy1->m_collisionFilterMask) != 0; + collides = collides && (childProxy1->m_collisionFilterGroup & childProxy0->m_collisionFilterMask); return collides; } @@ -69,23 +82,32 @@ btMultiSapBroadphase::~btMultiSapBroadphase() } } + +void btMultiSapBroadphase::buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax) +{ + m_optimizedAabbTree = new btOptimizedBvh(); + m_optimizedAabbTree->setQuantizationValues(bvhAabbMin,bvhAabbMax); + QuantizedNodeArray& nodes = m_optimizedAabbTree->getLeafNodeArray(); + for (int i=0;igetBroadphaseAabb(aabbMin,aabbMax); + m_optimizedAabbTree->quantize(&node.m_quantizedAabbMin[0],aabbMin,0); + m_optimizedAabbTree->quantize(&node.m_quantizedAabbMax[0],aabbMax,1); + int partId = 0; + node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | i; + nodes.push_back(node); + } + m_optimizedAabbTree->buildInternal(); +} + btBroadphaseProxy* btMultiSapBroadphase::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher) { void* mem = btAlignedAlloc(sizeof(btMultiSapProxy),16); btMultiSapProxy* proxy = new (mem)btMultiSapProxy(aabbMin, aabbMax,shapeType,userPtr, collisionFilterGroup,collisionFilterMask); m_multiSapProxies.push_back(proxy); - ///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision - ///this is needed to be able to calculate the aabb overlap - btBroadphaseProxy* simpleProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,shapeType,userPtr,collisionFilterGroup,collisionFilterMask, dispatcher); - simpleProxy->m_multiSapParentProxy = proxy; - - mem = btAlignedAlloc(sizeof(btChildProxy),16); - btChildProxy* childProxyRef = new(mem) btChildProxy(); - childProxyRef->m_proxy = simpleProxy; - childProxyRef->m_childBroadphase = m_simpleBroadphase; - proxy->m_childProxies.push_back(childProxyRef); - ///this should deal with inserting/removal into child broadphases setAabb(proxy,aabbMin,aabbMax,dispatcher); return proxy; @@ -97,51 +119,248 @@ void btMultiSapBroadphase::destroyProxy(btBroadphaseProxy* proxy,btDispatcher* d btAssert(0); } + + +void btMultiSapBroadphase::addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase) +{ + void* mem = btAlignedAlloc(sizeof(btBridgeProxy),16); + btBridgeProxy* bridgeProxyRef = new(mem) btBridgeProxy(); + bridgeProxyRef->m_childProxy = childProxy; + bridgeProxyRef->m_childBroadphase = childBroadphase; + parentMultiSapProxy->m_bridgeProxies.push_back(bridgeProxyRef); +} + + +bool boxIsContainedWithinBox(const btVector3& amin,const btVector3& amax,const btVector3& bmin,const btVector3& bmax) +{ +return +amin.getX() >= bmin.getX() && amax.getX() <= bmax.getX() && +amin.getY() >= bmin.getY() && amax.getY() <= bmax.getY() && +amin.getZ() >= bmin.getZ() && amax.getZ() <= bmax.getZ(); +} + + + + + + +int doTree=1; +#include + void btMultiSapBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher) { btMultiSapProxy* multiProxy = static_cast(proxy); multiProxy->m_aabbMin = aabbMin; multiProxy->m_aabbMax = aabbMax; - - for (int i=0;im_childProxies.size();i++) + + + bool fullyContained = false; + bool alreadyInSimple = false; + + for (int i=0;im_bridgeProxies.size();i++) { - btChildProxy* childProxyRef = multiProxy->m_childProxies[i]; - childProxyRef->m_childBroadphase->setAabb(childProxyRef->m_proxy,aabbMin,aabbMax,dispatcher); + btVector3 worldAabbMin,worldAabbMax; + multiProxy->m_bridgeProxies[i]->m_childBroadphase->getBroadphaseAabb(worldAabbMin,worldAabbMax); + bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); + if (!overlapsBroadphase) + { + //remove it now + btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[i]; + + btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy; + bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher); + + multiProxy->m_bridgeProxies.swap( i,multiProxy->m_bridgeProxies.size()-1); + multiProxy->m_bridgeProxies.pop_back(); + + } + } + + + + + struct MyNodeOverlapCallback : public btNodeOverlapCallback + { + btMultiSapBroadphase* m_multiSap; + btMultiSapProxy* m_multiProxy; + btDispatcher* m_dispatcher; + + MyNodeOverlapCallback(btMultiSapBroadphase* multiSap,btMultiSapProxy* multiProxy,btDispatcher* dispatcher) + :m_multiSap(multiSap), + m_multiProxy(multiProxy), + m_dispatcher(dispatcher) + { + + } + + virtual void processNode(int nodeSubPart, int broadphaseIndex) + { + btBroadphaseInterface* childBroadphase = m_multiSap->getBroadphaseArray()[broadphaseIndex]; + + int containingBroadphaseIndex = -1; + //already found? + for (int i=0;im_bridgeProxies.size();i++) + { + + if (m_multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase) + { + containingBroadphaseIndex = i; + break; + } + } + if (containingBroadphaseIndex<0) + { + //add it + btBroadphaseProxy* childProxy = childBroadphase->createProxy(m_multiProxy->m_aabbMin,m_multiProxy->m_aabbMax,m_multiProxy->m_shapeType,m_multiProxy->m_clientObject,m_multiProxy->m_collisionFilterGroup,m_multiProxy->m_collisionFilterMask, m_dispatcher); + childProxy->m_multiSapParentProxy = m_multiProxy; + m_multiSap->addToChildBroadphase(m_multiProxy,childProxy,childBroadphase); + + } + } + }; + + MyNodeOverlapCallback myNodeCallback(this,multiProxy,dispatcher); + + + + if (doTree) + { + + m_optimizedAabbTree->reportAabbOverlappingNodex(&myNodeCallback,aabbMin,aabbMax); + } + + + /*if (!stopUpdating1) + { + + //find broadphase that contain this multiProxy + int numChildBroadphases = getBroadphaseArray().size(); + for (int i=0;igetBroadphaseAabb(worldAabbMin,worldAabbMax); + bool overlapsBroadphase = TestAabbAgainstAabb2(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); + + // fullyContained = fullyContained || boxIsContainedWithinBox(worldAabbMin,worldAabbMax,multiProxy->m_aabbMin,multiProxy->m_aabbMax); + int containingBroadphaseIndex = -1; + + //if already contains this + + for (int i=0;im_bridgeProxies.size();i++) + { + if (multiProxy->m_bridgeProxies[i]->m_childBroadphase == childBroadphase) + { + containingBroadphaseIndex = i; + } + alreadyInSimple = alreadyInSimple || (multiProxy->m_bridgeProxies[i]->m_childBroadphase == m_simpleBroadphase); + } + + if (overlapsBroadphase) + { + if (containingBroadphaseIndex<0) + { + btBroadphaseProxy* childProxy = childBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); + childProxy->m_multiSapParentProxy = multiProxy; + addToChildBroadphase(multiProxy,childProxy,childBroadphase); + } + } else + { + if (containingBroadphaseIndex>=0) + { + //remove + btBridgeProxy* bridgeProxy = multiProxy->m_bridgeProxies[containingBroadphaseIndex]; + + btBroadphaseProxy* childProxy = bridgeProxy->m_childProxy; + bridgeProxy->m_childBroadphase->destroyProxy(childProxy,dispatcher); + + multiProxy->m_bridgeProxies.swap( containingBroadphaseIndex,multiProxy->m_bridgeProxies.size()-1); + multiProxy->m_bridgeProxies.pop_back(); + } + } + } + + + ///If we are in no other child broadphase, stick the proxy in the global 'simple' broadphase (brute force) + ///hopefully we don't end up with many entries here (can assert/provide feedback on stats) + if (0)//!multiProxy->m_bridgeProxies.size()) + { + ///we don't pass the userPtr but our multisap proxy. We need to patch this, before processing an actual collision + ///this is needed to be able to calculate the aabb overlap + btBroadphaseProxy* childProxy = m_simpleBroadphase->createProxy(aabbMin,aabbMax,multiProxy->m_shapeType,multiProxy->m_clientObject,multiProxy->m_collisionFilterGroup,multiProxy->m_collisionFilterMask, dispatcher); + childProxy->m_multiSapParentProxy = multiProxy; + addToChildBroadphase(multiProxy,childProxy,m_simpleBroadphase); + } + } + */ + + + //update + for (int i=0;im_bridgeProxies.size();i++) + { + btBridgeProxy* bridgeProxyRef = multiProxy->m_bridgeProxies[i]; + bridgeProxyRef->m_childBroadphase->setAabb(bridgeProxyRef->m_childProxy,aabbMin,aabbMax,dispatcher); } } - +bool stopUpdating=false; + + + ///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb void btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) { + class btMultiSapBroadphasePairSortPredicate +{ + public: + + bool operator() ( const btBroadphasePair& a1, const btBroadphasePair& b1 ) + { + btMultiSapProxy* aProxy0 = a1.m_pProxy0 ? (btMultiSapProxy*)a1.m_pProxy0->m_multiSapParentProxy : 0; + btMultiSapProxy* aProxy1 = a1.m_pProxy1 ? (btMultiSapProxy*)a1.m_pProxy1->m_multiSapParentProxy : 0; + btMultiSapProxy* bProxy0 = b1.m_pProxy0 ? (btMultiSapProxy*)b1.m_pProxy0->m_multiSapParentProxy : 0; + btMultiSapProxy* bProxy1 = b1.m_pProxy1 ? (btMultiSapProxy*)b1.m_pProxy1->m_multiSapParentProxy : 0; + + return aProxy0 > bProxy0 || + (aProxy0 == bProxy0 && aProxy1 > bProxy1) || + (aProxy0 == bProxy0 && aProxy1 == bProxy1 && a1.m_algorithm > b1.m_algorithm); + } +}; + m_simpleBroadphase->calculateOverlappingPairs(dispatcher); - if (m_overlappingPairs->hasDeferredRemoval()) + if (!stopUpdating && getOverlappingPairCache()->hasDeferredRemoval()) { + + btBroadphasePairArray& overlappingPairArray = getOverlappingPairCache()->getOverlappingPairArray(); - - btBroadphasePairArray& overlappingPairArray = m_overlappingPairs->getOverlappingPairArray(); - //perform a sort, to find duplicates and to sort 'invalid' pairs to the end - overlappingPairArray.heapSort(btBroadphasePairSortPredicate()); + overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate()); overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); m_invalidPair = 0; + + int i; btBroadphasePair previousPair; previousPair.m_pProxy0 = 0; previousPair.m_pProxy1 = 0; previousPair.m_algorithm = 0; - int i; - + for (i=0;im_multiSapParentProxy : 0; + btMultiSapProxy* aProxy1 = pair.m_pProxy1 ? (btMultiSapProxy*)pair.m_pProxy1->m_multiSapParentProxy : 0; + btMultiSapProxy* bProxy0 = previousPair.m_pProxy0 ? (btMultiSapProxy*)previousPair.m_pProxy0->m_multiSapParentProxy : 0; + btMultiSapProxy* bProxy1 = previousPair.m_pProxy1 ? (btMultiSapProxy*)previousPair.m_pProxy1->m_multiSapParentProxy : 0; + + bool isDuplicate = (aProxy0 == bProxy0) && (aProxy1 == bProxy1); + (pair == previousPair); previousPair = pair; @@ -168,7 +387,7 @@ void btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) if (needsRemoval) { - m_overlappingPairs->cleanOverlappingPair(pair,dispatcher); + getOverlappingPairCache()->cleanOverlappingPair(pair,dispatcher); // m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1); // m_overlappingPairArray.pop_back(); @@ -185,23 +404,27 @@ void btMultiSapBroadphase::calculateOverlappingPairs(btDispatcher* dispatcher) #ifdef CLEAN_INVALID_PAIRS //perform a sort, to sort 'invalid' pairs to the end - overlappingPairArray.heapSort(btBroadphasePairSortPredicate()); + overlappingPairArray.heapSort(btMultiSapBroadphasePairSortPredicate()); overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair); m_invalidPair = 0; #endif//CLEAN_INVALID_PAIRS - + + //printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size()); } + } bool btMultiSapBroadphase::testAabbOverlap(btBroadphaseProxy* childProxy0,btBroadphaseProxy* childProxy1) { - btMultiSapProxy* multiSapProxy0 = (btMultiSapProxy*)childProxy0->m_multiSapParentProxy; + btMultiSapProxy* multiSapProxy0 = (btMultiSapProxy*)childProxy0->m_multiSapParentProxy; btMultiSapProxy* multiSapProxy1 = (btMultiSapProxy*)childProxy1->m_multiSapParentProxy; return TestAabbAgainstAabb2(multiSapProxy0->m_aabbMin,multiSapProxy0->m_aabbMax, multiSapProxy1->m_aabbMin,multiSapProxy1->m_aabbMax); } + + diff --git a/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h b/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h index 1ee609b8d..a5c1d072b 100644 --- a/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h +++ b/src/BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h @@ -19,11 +19,12 @@ subject to the following restrictions: #include "LinearMath/btAlignedObjectArray.h" #include "btOverlappingPairCache.h" -class btAxisSweep3; + +class btBroadphaseInterface; class btSimpleBroadphase; -typedef btAlignedObjectArray btSapBroadphaseArray; +typedef btAlignedObjectArray btSapBroadphaseArray; ///multi SAP broadphase ///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=328 @@ -36,40 +37,43 @@ class btMultiSapBroadphase :public btBroadphaseInterface btOverlappingPairCache* m_overlappingPairs; + class btOptimizedBvh* m_optimizedAabbTree; + + bool m_ownsPairCache; btOverlapFilterCallback* m_filterCallback; int m_invalidPair; - struct btChildProxy + struct btBridgeProxy { - btBroadphaseProxy* m_proxy; + btBroadphaseProxy* m_childProxy; btBroadphaseInterface* m_childBroadphase; }; + public: struct btMultiSapProxy : public btBroadphaseProxy { ///array with all the entries that this proxy belongs to - btAlignedObjectArray m_childProxies; + btAlignedObjectArray m_bridgeProxies; btVector3 m_aabbMin; btVector3 m_aabbMax; int m_shapeType; - void* m_userPtr; + +/* void* m_userPtr; short int m_collisionFilterGroup; short int m_collisionFilterMask; - +*/ btMultiSapProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) - :m_aabbMin(aabbMin), + :btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask), + m_aabbMin(aabbMin), m_aabbMax(aabbMax), - m_shapeType(shapeType), - m_userPtr(userPtr), - m_collisionFilterGroup(collisionFilterGroup), - m_collisionFilterMask(collisionFilterMask) + m_shapeType(shapeType) { } @@ -79,18 +83,21 @@ public: protected: + void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase); + btAlignedObjectArray m_multiSapProxies; public: btMultiSapBroadphase(int maxProxies = 16384,btOverlappingPairCache* pairCache=0); - btSapBroadphaseArray getBroadphaseArray() + + btSapBroadphaseArray& getBroadphaseArray() { return m_sapBroadphases; } - const btSapBroadphaseArray getBroadphaseArray() const + const btSapBroadphaseArray& getBroadphaseArray() const { return m_sapBroadphases; } @@ -114,6 +121,17 @@ public: { return m_overlappingPairs; } + + ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame + ///will add some transform later + virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const + { + aabbMin.setValue(-1e30f,-1e30f,-1e30f); + aabbMax.setValue(1e30f,1e30f,1e30f); + } + + void buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax); + }; #endif //BT_MULTI_SAP_BROADPHASE diff --git a/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h b/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h index 09367a79d..6685944d2 100644 --- a/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h +++ b/src/BulletCollision/BroadphaseCollision/btSimpleBroadphase.h @@ -139,6 +139,13 @@ public: bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); + ///getAabb returns the axis aligned bounding box in the 'global' coordinate frame + ///will add some transform later + virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const + { + aabbMin.setValue(-1e30f,-1e30f,-1e30f); + aabbMax.setValue(1e30f,1e30f,1e30f); + } };