Bullet Collision Detection & Physics Library: btCollisionDispatcher.h Source File

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btCollisionDispatcher.h
Go to the documentation of this file.
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
16 #ifndef BT_COLLISION__DISPATCHER_H
17 #define BT_COLLISION__DISPATCHER_H
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;
38 typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
39
40
43 class btCollisionDispatcher : public btDispatcher
44 {
45
46 protected:
47
48 int m_dispatcherFlags;
49
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:
66
67 enum DispatcherFlags
68 {
69 CD_STATIC_STATIC_REPORTED = 1,
70 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2,
71 CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4
72 };
73
74 int getDispatcherFlags() const
75 {
76 return m_dispatcherFlags;
77 }
78
79 void setDispatcherFlags(int flags)
80 {
81 m_dispatcherFlags = flags;
82 }
83
85 void registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
86
87 int getNumManifolds() const
88 {
89 return int( m_manifoldsPtr.size());
90 }
91
92 btPersistentManifold** getInternalManifoldPointer()
93 {
94 return m_manifoldsPtr.size()? &m_manifoldsPtr[0] : 0;
95 }
96
97 btPersistentManifold* getManifoldByIndexInternal(int index)
98 {
99 return m_manifoldsPtr[index];
100 }
101
102 const btPersistentManifold* getManifoldByIndexInternal(int index) const
103 {
104 return m_manifoldsPtr[index];
105 }
106
107 btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration);
108
109 virtual ~btCollisionDispatcher();
110
111 virtual btPersistentManifold* getNewManifold(const btCollisionObject* b0,const btCollisionObject* b1);
112
113 virtual void releaseManifold(btPersistentManifold* manifold);
114
115
116 virtual void clearManifold(btPersistentManifold* manifold);
117
118 btCollisionAlgorithm* findAlgorithm(const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,btPersistentManifold* sharedManifold = 0);
119
120 virtual bool needsCollision(const btCollisionObject* body0,const btCollisionObject* body1);
121
122 virtual bool needsResponse(const btCollisionObject* body0,const btCollisionObject* body1);
123
124 virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
125
126 void setNearCallback(btNearCallback nearCallback)
127 {
128 m_nearCallback = nearCallback;
129 }
130
131 btNearCallback getNearCallback() const
132 {
133 return m_nearCallback;
134 }
135
136 //by default, Bullet will use this near callback
137 static void defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
138
139 virtual void* allocateCollisionAlgorithm(int size);
140
141 virtual void freeCollisionAlgorithm(void* ptr);
142
143 btCollisionConfiguration* getCollisionConfiguration()
144 {
145 return m_collisionConfiguration;
146 }
147
148 const btCollisionConfiguration* getCollisionConfiguration() const
149 {
150 return m_collisionConfiguration;
151 }
152
153 void setCollisionConfiguration(btCollisionConfiguration* config)
154 {
155 m_collisionConfiguration = config;
156 }
157
158 virtual btPoolAllocator* getInternalManifoldPool()
159 {
160 return m_persistentManifoldPoolAllocator;
161 }
162
163 virtual const btPoolAllocator* getInternalManifoldPool() const
164 {
165 return m_persistentManifoldPoolAllocator;
166 }
167
168 };
169
170 #endif //BT_COLLISION__DISPATCHER_H
171
btCollisionDispatcher::setDispatcherFlags
void setDispatcherFlags(int flags)
Definition: btCollisionDispatcher.h:79
btCollisionDispatcher::m_collisionConfiguration
btCollisionConfiguration * m_collisionConfiguration
Definition: btCollisionDispatcher.h:62
btPersistentManifold
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
Definition: btPersistentManifold.h:54
btNearCallback
void(* btNearCallback)(btBroadphasePair &collisionPair, btCollisionDispatcher &dispatcher, const btDispatcherInfo &dispatchInfo)
user can override this nearcallback for collision filtering and more finegrained control over collisi...
Definition: btCollisionDispatcher.h:38
btCollisionDispatcher::getManifoldByIndexInternal
btPersistentManifold * getManifoldByIndexInternal(int index)
Definition: btCollisionDispatcher.h:97
btCollisionDispatcher::registerCollisionCreateFunc
void registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
registerCollisionCreateFunc allows registration of custom/alternative collision create functions ...
Definition: btCollisionDispatcher.cpp:62
btCollisionDispatcher::getDispatcherFlags
int getDispatcherFlags() const
Definition: btCollisionDispatcher.h:74
btCollisionDispatcher::CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION
Definition: btCollisionDispatcher.h:71
btAlignedObjectArray< btPersistentManifold * >
btManifoldResult.h
btCollisionDispatcher::getCollisionConfiguration
btCollisionConfiguration * getCollisionConfiguration()
Definition: btCollisionDispatcher.h:143
btCollisionDispatcher::m_dispatcherFlags
int m_dispatcherFlags
Definition: btCollisionDispatcher.h:48
size
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
btCollisionConfiguration
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
Definition: btCollisionConfiguration.h:26
btCollisionDispatcher
btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs...
Definition: btCollisionDispatcher.h:43
btPersistentManifold.h
btCollisionDispatcher::freeCollisionAlgorithm
virtual void freeCollisionAlgorithm(void *ptr)
Definition: btCollisionDispatcher.cpp:305
btManifoldResult
btManifoldResult is a helper class to manage contact results.
Definition: btManifoldResult.h:39
btCollisionDispatcher::setNearCallback
void setNearCallback(btNearCallback nearCallback)
Definition: btCollisionDispatcher.h:126
btCollisionCreateFunc.h
btCollisionDispatcher::releaseManifold
virtual void releaseManifold(btPersistentManifold *manifold)
Definition: btCollisionDispatcher.cpp:118
btOverlappingPairCache
The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
Definition: btOverlappingPairCache.h:60
btCollisionDispatcher::setCollisionConfiguration
void setCollisionConfiguration(btCollisionConfiguration *config)
Definition: btCollisionDispatcher.h:153
btCollisionDispatcher::needsCollision
virtual bool needsCollision(const btCollisionObject *body0, const btCollisionObject *body1)
Definition: btCollisionDispatcher.cpp:171
btCollisionDispatcher::CD_STATIC_STATIC_REPORTED
Definition: btCollisionDispatcher.h:69
btCollisionDispatcher::defaultNearCallback
static void defaultNearCallback(btBroadphasePair &collisionPair, btCollisionDispatcher &dispatcher, const btDispatcherInfo &dispatchInfo)
Definition: btCollisionDispatcher.cpp:254
btCollisionDispatcher::m_doubleDispatch
btCollisionAlgorithmCreateFunc * m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]
Definition: btCollisionDispatcher.h:60
btAlignedObjectArray::size
int size() const
return the number of elements in the array
Definition: btAlignedObjectArray.h:149
btCollisionDispatcher::m_defaultManifoldResult
btManifoldResult m_defaultManifoldResult
Definition: btCollisionDispatcher.h:52
btCollisionDispatcher::findAlgorithm
btCollisionAlgorithm * findAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, btPersistentManifold *sharedManifold=0)
Definition: btCollisionDispatcher.cpp:145
btCollisionDispatcher::m_manifoldsPtr
btAlignedObjectArray< btPersistentManifold * > m_manifoldsPtr
Definition: btCollisionDispatcher.h:50
btCollisionAlgorithmCreateFunc
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.
Definition: btCollisionCreateFunc.h:26
btCollisionDispatcher::getManifoldByIndexInternal
const btPersistentManifold * getManifoldByIndexInternal(int index) const
Definition: btCollisionDispatcher.h:102
btCollisionObject
btCollisionObject can be used to manage collision detection objects.
Definition: btCollisionObject.h:49
btCollisionDispatcher::clearManifold
virtual void clearManifold(btPersistentManifold *manifold)
Definition: btCollisionDispatcher.cpp:112
btIDebugDraw
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:28
btBroadphaseProxy.h
btCollisionDispatcher::getNewManifold
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)
Definition: btCollisionDispatcher.cpp:71
btCollisionDispatcher::getInternalManifoldPool
virtual const btPoolAllocator * getInternalManifoldPool() const
Definition: btCollisionDispatcher.h:163
btCollisionDispatcher::m_nearCallback
btNearCallback m_nearCallback
Definition: btCollisionDispatcher.h:54
MAX_BROADPHASE_COLLISION_TYPES
Definition: btBroadphaseProxy.h:78
btCollisionDispatcher::btCollisionDispatcher
btCollisionDispatcher(btCollisionConfiguration *collisionConfiguration)
Definition: btCollisionDispatcher.cpp:37
btCollisionDispatcher::CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD
Definition: btCollisionDispatcher.h:70
btPoolAllocator
The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamica...
Definition: btPoolAllocator.h:23
btCollisionDispatcher::dispatchAllCollisionPairs
virtual void dispatchAllCollisionPairs(btOverlappingPairCache *pairCache, const btDispatcherInfo &dispatchInfo, btDispatcher *dispatcher)
Definition: btCollisionDispatcher.cpp:238
btCollisionDispatcher::getCollisionConfiguration
const btCollisionConfiguration * getCollisionConfiguration() const
Definition: btCollisionDispatcher.h:148
btCollisionDispatcher::m_collisionAlgorithmPoolAllocator
btPoolAllocator * m_collisionAlgorithmPoolAllocator
Definition: btCollisionDispatcher.h:56
btCollisionDispatcher::needsResponse
virtual bool needsResponse(const btCollisionObject *body0, const btCollisionObject *body1)
Definition: btCollisionDispatcher.cpp:160
btAlignedObjectArray.h
btCollisionDispatcher::~btCollisionDispatcher
virtual ~btCollisionDispatcher()
Definition: btCollisionDispatcher.cpp:67
btCollisionDispatcher::allocateCollisionAlgorithm
virtual void * allocateCollisionAlgorithm(int size)
Definition: btCollisionDispatcher.cpp:294
btDispatcherInfo
Definition: btDispatcher.h:30
btCollisionDispatcher::getNearCallback
btNearCallback getNearCallback() const
Definition: btCollisionDispatcher.h:131
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:69
btCollisionDispatcher::DispatcherFlags
DispatcherFlags
Definition: btCollisionDispatcher.h:67
btCollisionAlgorithm
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
Definition: btCollisionAlgorithm.h:55
btCollisionDispatcher::m_persistentManifoldPoolAllocator
btPoolAllocator * m_persistentManifoldPoolAllocator
Definition: btCollisionDispatcher.h:58
btCollisionObjectWrapper
Definition: btCollisionObjectWrapper.h:17
btCollisionDispatcher::getInternalManifoldPool
virtual btPoolAllocator * getInternalManifoldPool()
Definition: btCollisionDispatcher.h:158
btDispatcher.h
btCollisionDispatcher::getNumManifolds
int getNumManifolds() const
Definition: btCollisionDispatcher.h:87
btCollisionDispatcher::getInternalManifoldPointer
btPersistentManifold ** getInternalManifoldPointer()
Definition: btCollisionDispatcher.h:92
btBroadphasePair
The btBroadphasePair class contains a pair of aabb-overlapping objects.
Definition: btBroadphaseProxy.h:186