Back to index

supertuxkart  0.5+dfsg1
btMultiSapBroadphase.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 #ifndef BT_MULTI_SAP_BROADPHASE
00016 #define BT_MULTI_SAP_BROADPHASE
00017 
00018 #include "btBroadphaseInterface.h"
00019 #include "LinearMath/btAlignedObjectArray.h"
00020 #include "btOverlappingPairCache.h"
00021 
00022 
00023 class btBroadphaseInterface;
00024 class btSimpleBroadphase;
00025 
00026 
00027 typedef btAlignedObjectArray<btBroadphaseInterface*> btSapBroadphaseArray;
00028 
00032 class btMultiSapBroadphase :public btBroadphaseInterface
00033 {
00034        btSapBroadphaseArray m_sapBroadphases;
00035        
00036        btSimpleBroadphase*         m_simpleBroadphase;
00037 
00038        btOverlappingPairCache*     m_overlappingPairs;
00039 
00040        class btOptimizedBvh*                     m_optimizedAabbTree;
00041 
00042 
00043        bool                               m_ownsPairCache;
00044        
00045        btOverlapFilterCallback*    m_filterCallback;
00046 
00047        int                  m_invalidPair;
00048 
00049        struct btBridgeProxy
00050        {
00051               btBroadphaseProxy*          m_childProxy;
00052               btBroadphaseInterface*      m_childBroadphase;
00053        };
00054 
00055 
00056 public:
00057 
00058        struct btMultiSapProxy      : public btBroadphaseProxy
00059        {
00060 
00062               btAlignedObjectArray<btBridgeProxy*> m_bridgeProxies;
00063               btVector3     m_aabbMin;
00064               btVector3     m_aabbMax;
00065 
00066               int    m_shapeType;
00067 
00068 /*            void*  m_userPtr;
00069               short int     m_collisionFilterGroup;
00070               short int     m_collisionFilterMask;
00071 */
00072               btMultiSapProxy(const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask)
00073                      :btBroadphaseProxy(userPtr,collisionFilterGroup,collisionFilterMask),
00074                      m_aabbMin(aabbMin),
00075                      m_aabbMax(aabbMax),
00076                      m_shapeType(shapeType)
00077               {
00078                      m_multiSapParentProxy =this;
00079               }
00080 
00081               
00082        };
00083 
00084 protected:
00085 
00086        void   addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface*       childBroadphase);
00087 
00088        btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
00089 
00090 public:
00091 
00092        btMultiSapBroadphase(int maxProxies = 16384,btOverlappingPairCache* pairCache=0);
00093 
00094 
00095        btSapBroadphaseArray&       getBroadphaseArray()
00096        {
00097               return m_sapBroadphases;
00098        }
00099 
00100        const btSapBroadphaseArray& getBroadphaseArray() const
00101        {
00102               return m_sapBroadphases;
00103        }
00104 
00105        virtual ~btMultiSapBroadphase();
00106 
00107        virtual btBroadphaseProxy*  createProxy(  const btVector3& aabbMin,  const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
00108        virtual void  destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
00109        virtual void  setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
00110        
00112        virtual void  calculateOverlappingPairs(btDispatcher* dispatcher);
00113 
00114        bool   testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
00115 
00116        virtual       btOverlappingPairCache*     getOverlappingPairCache()
00117        {
00118               return m_overlappingPairs;
00119        }
00120        virtual       const btOverlappingPairCache*      getOverlappingPairCache() const
00121        {
00122               return m_overlappingPairs;
00123        }
00124 
00127        virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
00128        {
00129               aabbMin.setValue(-1e30f,-1e30f,-1e30f);
00130               aabbMax.setValue(1e30f,1e30f,1e30f);
00131        }
00132 
00133        void   buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax);
00134 
00135        virtual void  printStats();
00136 
00137        void quicksort (btBroadphasePairArray& a, int lo, int hi);
00138 
00139 };
00140 
00141 #endif //BT_MULTI_SAP_BROADPHASE