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, const btDispatcherInfo& dispatchInfo);
00039 
00040 
00043 class btCollisionDispatcher : public btDispatcher
00044 {
00045         int             m_dispatcherFlags;
00046         
00047         btAlignedObjectArray<btPersistentManifold*>     m_manifoldsPtr;
00048 
00049         btManifoldResult        m_defaultManifoldResult;
00050 
00051         btNearCallback          m_nearCallback;
00052         
00053         btPoolAllocator*        m_collisionAlgorithmPoolAllocator;
00054 
00055         btPoolAllocator*        m_persistentManifoldPoolAllocator;
00056 
00057         btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
00058 
00059         btCollisionConfiguration*       m_collisionConfiguration;
00060 
00061 
00062 public:
00063 
00064         enum DispatcherFlags
00065         {
00066                 CD_STATIC_STATIC_REPORTED = 1,
00067                 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2
00068         };
00069 
00070         int     getDispatherFlags() const
00071         {
00072                 return m_dispatcherFlags;
00073         }
00074 
00075         void    setDispatcherFlags(int flags)
00076         {
00077         (void) flags;
00078                 m_dispatcherFlags = 0;
00079         }
00080 
00082         void    registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
00083 
00084         int     getNumManifolds() const
00085         { 
00086                 return int( m_manifoldsPtr.size());
00087         }
00088 
00089         btPersistentManifold**  getInternalManifoldPointer()
00090         {
00091                 return &m_manifoldsPtr[0];
00092         }
00093 
00094          btPersistentManifold* getManifoldByIndexInternal(int index)
00095         {
00096                 return m_manifoldsPtr[index];
00097         }
00098 
00099          const btPersistentManifold* getManifoldByIndexInternal(int index) const
00100         {
00101                 return m_manifoldsPtr[index];
00102         }
00103 
00104         btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration);
00105 
00106         virtual ~btCollisionDispatcher();
00107 
00108         virtual btPersistentManifold*   getNewManifold(void* b0,void* b1);
00109         
00110         virtual void releaseManifold(btPersistentManifold* manifold);
00111 
00112 
00113         virtual void clearManifold(btPersistentManifold* manifold);
00114 
00115                         
00116         btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
00117                 
00118         virtual bool    needsCollision(btCollisionObject* body0,btCollisionObject* body1);
00119         
00120         virtual bool    needsResponse(btCollisionObject* body0,btCollisionObject* body1);
00121         
00122         virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
00123 
00124         void    setNearCallback(btNearCallback  nearCallback)
00125         {
00126                 m_nearCallback = nearCallback; 
00127         }
00128 
00129         btNearCallback  getNearCallback() const
00130         {
00131                 return m_nearCallback;
00132         }
00133 
00134         //by default, Bullet will use this near callback
00135         static void  defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
00136 
00137         virtual void* allocateCollisionAlgorithm(int size);
00138 
00139         virtual void freeCollisionAlgorithm(void* ptr);
00140 
00141         btCollisionConfiguration*       getCollisionConfiguration()
00142         {
00143                 return m_collisionConfiguration;
00144         }
00145 
00146         const btCollisionConfiguration* getCollisionConfiguration() const
00147         {
00148                 return m_collisionConfiguration;
00149         }
00150 
00151         void    setCollisionConfiguration(btCollisionConfiguration* config)
00152         {
00153                 m_collisionConfiguration = config;
00154         }
00155 
00156 };
00157 
00158 #endif //COLLISION__DISPATCHER_H
00159 

Generated on Mon Feb 15 22:17:02 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1