Back to index

supertuxkart  0.5+dfsg1
btCollisionDispatcher.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 
00016 #ifndef COLLISION__DISPATCHER_H
00017 #define COLLISION__DISPATCHER_H
00018 
00019 #include "BulletCollision/BroadphaseCollision/btDispatcher.h"
00020 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
00021 
00022 #include "BulletCollision/CollisionDispatch/btManifoldResult.h"
00023 
00024 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00025 #include "LinearMath/btAlignedObjectArray.h"
00026 
00027 class btIDebugDraw;
00028 class btOverlappingPairCache;
00029 class btPoolAllocator;
00030 class btCollisionConfiguration;
00031 
00032 #include "btCollisionCreateFunc.h"
00033 
00034 #define USE_DISPATCH_REGISTRY_ARRAY 1
00035 
00036 class btCollisionDispatcher;
00038 typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, btDispatcherInfo& dispatchInfo);
00039 
00040 
00043 class btCollisionDispatcher : public btDispatcher
00044 {
00045        int m_count;
00046        
00047        btAlignedObjectArray<btPersistentManifold*>      m_manifoldsPtr;
00048 
00049        bool m_useIslands;
00050 
00051        bool   m_staticWarningReported;
00052        
00053        btManifoldResult     m_defaultManifoldResult;
00054 
00055        btNearCallback              m_nearCallback;
00056        
00057        btPoolAllocator*     m_collisionAlgorithmPoolAllocator;
00058 
00059        btPoolAllocator*     m_persistentManifoldPoolAllocator;
00060 
00061        btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
00062        
00063 
00064        btCollisionConfiguration*   m_collisionConfiguration;
00065 
00066 
00067 public:
00068 
00070        void   registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
00071 
00072        int    getNumManifolds() const
00073        { 
00074               return int( m_manifoldsPtr.size());
00075        }
00076 
00077        btPersistentManifold**      getInternalManifoldPointer()
00078        {
00079               return &m_manifoldsPtr[0];
00080        }
00081 
00082         btPersistentManifold* getManifoldByIndexInternal(int index)
00083        {
00084               return m_manifoldsPtr[index];
00085        }
00086 
00087         const btPersistentManifold* getManifoldByIndexInternal(int index) const
00088        {
00089               return m_manifoldsPtr[index];
00090        }
00091 
00092        btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration);
00093 
00094        virtual ~btCollisionDispatcher();
00095 
00096        virtual btPersistentManifold*      getNewManifold(void* b0,void* b1);
00097        
00098        virtual void releaseManifold(btPersistentManifold* manifold);
00099 
00100 
00101        virtual void clearManifold(btPersistentManifold* manifold);
00102 
00103                      
00104        btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
00105               
00106        virtual bool  needsCollision(btCollisionObject* body0,btCollisionObject* body1);
00107        
00108        virtual bool  needsResponse(btCollisionObject* body0,btCollisionObject* body1);
00109        
00110        virtual void  dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher);
00111 
00112        void   setNearCallback(btNearCallback     nearCallback)
00113        {
00114               m_nearCallback = nearCallback; 
00115        }
00116 
00117        btNearCallback       getNearCallback() const
00118        {
00119               return m_nearCallback;
00120        }
00121 
00122        //by default, Bullet will use this near callback
00123        static void  defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, btDispatcherInfo& dispatchInfo);
00124 
00125        virtual       void* allocateCollisionAlgorithm(int size);
00126 
00127        virtual       void freeCollisionAlgorithm(void* ptr);
00128 
00129        btCollisionConfiguration*   getCollisionConfiguration()
00130        {
00131               return m_collisionConfiguration;
00132        }
00133 
00134        const btCollisionConfiguration*    getCollisionConfiguration() const
00135        {
00136               return m_collisionConfiguration;
00137        }
00138 
00139        void   setCollisionConfiguration(btCollisionConfiguration* config)
00140        {
00141               m_collisionConfiguration = config;
00142        }
00143 
00144 };
00145 
00146 #endif //COLLISION__DISPATCHER_H
00147