00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
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