Bullet Collision Detection & Physics Library
btCollisionDispatcher.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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
21
23
26
27class btIDebugDraw;
29class btPoolAllocator;
31
33
34#define USE_DISPATCH_REGISTRY_ARRAY 1
35
38typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
39
43{
44protected:
46
48
50
52
54
56
58
60
61public:
63 {
67 };
68
70 {
71 return m_dispatcherFlags;
72 }
73
74 void setDispatcherFlags(int flags)
75 {
76 m_dispatcherFlags = flags;
77 }
78
80 void registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
81
82 void registerClosestPointsCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
83
84 int getNumManifolds() const
85 {
86 return int(m_manifoldsPtr.size());
87 }
88
90 {
91 return m_manifoldsPtr.size() ? &m_manifoldsPtr[0] : 0;
92 }
93
95 {
96 btAssert(index>=0);
98 return m_manifoldsPtr[index];
99 }
100
102 {
103 btAssert(index>=0);
105 return m_manifoldsPtr[index];
106 }
107
108 btCollisionDispatcher(btCollisionConfiguration* collisionConfiguration);
109
110 virtual ~btCollisionDispatcher();
111
113
114 virtual void releaseManifold(btPersistentManifold* manifold);
115
116 virtual void clearManifold(btPersistentManifold* manifold);
117
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
127 {
128 m_nearCallback = nearCallback;
129 }
130
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
144 {
146 }
147
149 {
151 }
152
154 {
156 }
157
159 {
161 }
162
164 {
166 }
167};
168
169#endif //BT_COLLISION__DISPATCHER_H
@ MAX_BROADPHASE_COLLISION_TYPES
void(* btNearCallback)(btBroadphasePair &collisionPair, btCollisionDispatcher &dispatcher, const btDispatcherInfo &dispatchInfo)
user can override this nearcallback for collision filtering and more finegrained control over collisi...
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
ebtDispatcherQueryType
Definition: btDispatcher.h:69
#define btAssert(x)
Definition: btScalar.h:153
int size() const
return the number of elements in the array
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size,...
btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
btCollisionAlgorithmCreateFunc * m_doubleDispatchClosestPoints[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]
const btPersistentManifold * getManifoldByIndexInternal(int index) const
virtual const btPoolAllocator * getInternalManifoldPool() const
virtual void releaseManifold(btPersistentManifold *manifold)
void registerClosestPointsCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
btCollisionConfiguration * m_collisionConfiguration
virtual bool needsCollision(const btCollisionObject *body0, const btCollisionObject *body1)
btCollisionConfiguration * getCollisionConfiguration()
void setCollisionConfiguration(btCollisionConfiguration *config)
btPersistentManifold ** getInternalManifoldPointer()
btCollisionDispatcher(btCollisionConfiguration *collisionConfiguration)
btNearCallback getNearCallback() const
void setNearCallback(btNearCallback nearCallback)
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)
virtual void freeCollisionAlgorithm(void *ptr)
btCollisionAlgorithmCreateFunc * m_doubleDispatchContactPoints[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]
static void defaultNearCallback(btBroadphasePair &collisionPair, btCollisionDispatcher &dispatcher, const btDispatcherInfo &dispatchInfo)
virtual void dispatchAllCollisionPairs(btOverlappingPairCache *pairCache, const btDispatcherInfo &dispatchInfo, btDispatcher *dispatcher)
btPoolAllocator * m_collisionAlgorithmPoolAllocator
virtual void clearManifold(btPersistentManifold *manifold)
virtual bool needsResponse(const btCollisionObject *body0, const btCollisionObject *body1)
btCollisionAlgorithm * findAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, btPersistentManifold *sharedManifold, ebtDispatcherQueryType queryType)
virtual void * allocateCollisionAlgorithm(int size)
const btCollisionConfiguration * getCollisionConfiguration() const
btAlignedObjectArray< btPersistentManifold * > m_manifoldsPtr
btPersistentManifold * getManifoldByIndexInternal(int index)
btPoolAllocator * m_persistentManifoldPoolAllocator
void registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
registerCollisionCreateFunc allows registration of custom/alternative collision create functions
void setDispatcherFlags(int flags)
virtual btPoolAllocator * getInternalManifoldPool()
btCollisionObject can be used to manage collision detection objects.
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
Definition: btIDebugDraw.h:27
The btOverlappingPairCache provides an interface for overlapping pair management (add,...
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamica...
The btBroadphasePair class contains a pair of aabb-overlapping objects.
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.