| [1963] | 1 | /* | 
|---|
|  | 2 | Bullet Continuous Collision Detection and Physics Library | 
|---|
|  | 3 | Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/ | 
|---|
|  | 4 |  | 
|---|
|  | 5 | This software is provided 'as-is', without any express or implied warranty. | 
|---|
|  | 6 | In no event will the authors be held liable for any damages arising from the use of this software. | 
|---|
|  | 7 | Permission is granted to anyone to use this software for any purpose, | 
|---|
|  | 8 | including commercial applications, and to alter it and redistribute it freely, | 
|---|
|  | 9 | subject to the following restrictions: | 
|---|
|  | 10 |  | 
|---|
|  | 11 | 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. | 
|---|
|  | 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. | 
|---|
|  | 13 | 3. This notice may not be removed or altered from any source distribution. | 
|---|
|  | 14 | */ | 
|---|
|  | 15 |  | 
|---|
| [8393] | 16 | #ifndef BT_COLLISION__DISPATCHER_H | 
|---|
|  | 17 | #define BT_COLLISION__DISPATCHER_H | 
|---|
| [1963] | 18 |  | 
|---|
|  | 19 | #include "BulletCollision/BroadphaseCollision/btDispatcher.h" | 
|---|
|  | 20 | #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" | 
|---|
|  | 21 |  | 
|---|
|  | 22 | #include "BulletCollision/CollisionDispatch/btManifoldResult.h" | 
|---|
|  | 23 |  | 
|---|
|  | 24 | #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" | 
|---|
|  | 25 | #include "LinearMath/btAlignedObjectArray.h" | 
|---|
|  | 26 |  | 
|---|
|  | 27 | class btIDebugDraw; | 
|---|
|  | 28 | class btOverlappingPairCache; | 
|---|
|  | 29 | class btPoolAllocator; | 
|---|
|  | 30 | class btCollisionConfiguration; | 
|---|
|  | 31 |  | 
|---|
|  | 32 | #include "btCollisionCreateFunc.h" | 
|---|
|  | 33 |  | 
|---|
|  | 34 | #define USE_DISPATCH_REGISTRY_ARRAY 1 | 
|---|
|  | 35 |  | 
|---|
|  | 36 | class btCollisionDispatcher; | 
|---|
|  | 37 | ///user can override this nearcallback for collision filtering and more finegrained control over collision detection | 
|---|
|  | 38 | typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo); | 
|---|
|  | 39 |  | 
|---|
|  | 40 |  | 
|---|
|  | 41 | ///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs. | 
|---|
|  | 42 | ///Time of Impact, Closest Points and Penetration Depth. | 
|---|
|  | 43 | class btCollisionDispatcher : public btDispatcher | 
|---|
|  | 44 | { | 
|---|
| [8393] | 45 |  | 
|---|
|  | 46 | protected: | 
|---|
|  | 47 |  | 
|---|
| [8351] | 48 | int             m_dispatcherFlags; | 
|---|
| [8393] | 49 |  | 
|---|
| [1963] | 50 | btAlignedObjectArray<btPersistentManifold*>     m_manifoldsPtr; | 
|---|
|  | 51 |  | 
|---|
|  | 52 | btManifoldResult        m_defaultManifoldResult; | 
|---|
|  | 53 |  | 
|---|
|  | 54 | btNearCallback          m_nearCallback; | 
|---|
|  | 55 |  | 
|---|
|  | 56 | btPoolAllocator*        m_collisionAlgorithmPoolAllocator; | 
|---|
|  | 57 |  | 
|---|
|  | 58 | btPoolAllocator*        m_persistentManifoldPoolAllocator; | 
|---|
|  | 59 |  | 
|---|
|  | 60 | btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; | 
|---|
|  | 61 |  | 
|---|
|  | 62 | btCollisionConfiguration*       m_collisionConfiguration; | 
|---|
|  | 63 |  | 
|---|
|  | 64 |  | 
|---|
|  | 65 | public: | 
|---|
| [10726] | 66 | BT_DECLARE_ALIGNED_ALLOCATOR(); | 
|---|
| [1963] | 67 |  | 
|---|
| [8351] | 68 | enum DispatcherFlags | 
|---|
|  | 69 | { | 
|---|
|  | 70 | CD_STATIC_STATIC_REPORTED = 1, | 
|---|
| [8393] | 71 | CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2, | 
|---|
|  | 72 | CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4 | 
|---|
| [8351] | 73 | }; | 
|---|
|  | 74 |  | 
|---|
|  | 75 | int     getDispatcherFlags() const | 
|---|
|  | 76 | { | 
|---|
|  | 77 | return m_dispatcherFlags; | 
|---|
|  | 78 | } | 
|---|
|  | 79 |  | 
|---|
|  | 80 | void    setDispatcherFlags(int flags) | 
|---|
|  | 81 | { | 
|---|
| [8393] | 82 | m_dispatcherFlags = flags; | 
|---|
| [8351] | 83 | } | 
|---|
|  | 84 |  | 
|---|
| [1963] | 85 | ///registerCollisionCreateFunc allows registration of custom/alternative collision create functions | 
|---|
|  | 86 | void    registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc); | 
|---|
|  | 87 |  | 
|---|
|  | 88 | int     getNumManifolds() const | 
|---|
|  | 89 | { | 
|---|
|  | 90 | return int( m_manifoldsPtr.size()); | 
|---|
|  | 91 | } | 
|---|
|  | 92 |  | 
|---|
|  | 93 | btPersistentManifold**  getInternalManifoldPointer() | 
|---|
|  | 94 | { | 
|---|
|  | 95 | return &m_manifoldsPtr[0]; | 
|---|
|  | 96 | } | 
|---|
|  | 97 |  | 
|---|
|  | 98 | btPersistentManifold* getManifoldByIndexInternal(int index) | 
|---|
|  | 99 | { | 
|---|
|  | 100 | return m_manifoldsPtr[index]; | 
|---|
|  | 101 | } | 
|---|
|  | 102 |  | 
|---|
|  | 103 | const btPersistentManifold* getManifoldByIndexInternal(int index) const | 
|---|
|  | 104 | { | 
|---|
|  | 105 | return m_manifoldsPtr[index]; | 
|---|
|  | 106 | } | 
|---|
|  | 107 |  | 
|---|
|  | 108 | btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration); | 
|---|
|  | 109 |  | 
|---|
|  | 110 | virtual ~btCollisionDispatcher(); | 
|---|
|  | 111 |  | 
|---|
|  | 112 | virtual btPersistentManifold*   getNewManifold(void* b0,void* b1); | 
|---|
|  | 113 |  | 
|---|
|  | 114 | virtual void releaseManifold(btPersistentManifold* manifold); | 
|---|
|  | 115 |  | 
|---|
|  | 116 |  | 
|---|
|  | 117 | virtual void clearManifold(btPersistentManifold* manifold); | 
|---|
|  | 118 |  | 
|---|
|  | 119 |  | 
|---|
|  | 120 | btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0); | 
|---|
|  | 121 |  | 
|---|
|  | 122 | virtual bool    needsCollision(btCollisionObject* body0,btCollisionObject* body1); | 
|---|
|  | 123 |  | 
|---|
|  | 124 | virtual bool    needsResponse(btCollisionObject* body0,btCollisionObject* body1); | 
|---|
|  | 125 |  | 
|---|
|  | 126 | virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ; | 
|---|
|  | 127 |  | 
|---|
|  | 128 | void    setNearCallback(btNearCallback  nearCallback) | 
|---|
|  | 129 | { | 
|---|
|  | 130 | m_nearCallback = nearCallback; | 
|---|
|  | 131 | } | 
|---|
|  | 132 |  | 
|---|
|  | 133 | btNearCallback  getNearCallback() const | 
|---|
|  | 134 | { | 
|---|
|  | 135 | return m_nearCallback; | 
|---|
|  | 136 | } | 
|---|
|  | 137 |  | 
|---|
|  | 138 | //by default, Bullet will use this near callback | 
|---|
|  | 139 | static void  defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo); | 
|---|
|  | 140 |  | 
|---|
|  | 141 | virtual void* allocateCollisionAlgorithm(int size); | 
|---|
|  | 142 |  | 
|---|
|  | 143 | virtual void freeCollisionAlgorithm(void* ptr); | 
|---|
|  | 144 |  | 
|---|
|  | 145 | btCollisionConfiguration*       getCollisionConfiguration() | 
|---|
|  | 146 | { | 
|---|
|  | 147 | return m_collisionConfiguration; | 
|---|
|  | 148 | } | 
|---|
|  | 149 |  | 
|---|
|  | 150 | const btCollisionConfiguration* getCollisionConfiguration() const | 
|---|
|  | 151 | { | 
|---|
|  | 152 | return m_collisionConfiguration; | 
|---|
|  | 153 | } | 
|---|
|  | 154 |  | 
|---|
|  | 155 | void    setCollisionConfiguration(btCollisionConfiguration* config) | 
|---|
|  | 156 | { | 
|---|
|  | 157 | m_collisionConfiguration = config; | 
|---|
|  | 158 | } | 
|---|
|  | 159 |  | 
|---|
| [8393] | 160 | virtual btPoolAllocator*        getInternalManifoldPool() | 
|---|
|  | 161 | { | 
|---|
|  | 162 | return m_persistentManifoldPoolAllocator; | 
|---|
|  | 163 | } | 
|---|
|  | 164 |  | 
|---|
|  | 165 | virtual const btPoolAllocator*  getInternalManifoldPool() const | 
|---|
|  | 166 | { | 
|---|
|  | 167 | return m_persistentManifoldPoolAllocator; | 
|---|
|  | 168 | } | 
|---|
|  | 169 |  | 
|---|
| [1963] | 170 | }; | 
|---|
|  | 171 |  | 
|---|
| [8393] | 172 | #endif //BT_COLLISION__DISPATCHER_H | 
|---|
| [1963] | 173 |  | 
|---|