Bullet Collision Detection & Physics Library
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 
21 
23 
26 
27 class btIDebugDraw;
29 class btPoolAllocator;
31 
32 #include "btCollisionCreateFunc.h"
33 
34 #define USE_DISPATCH_REGISTRY_ARRAY 1
35 
38 typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
39 
40 
44 {
45 
46 protected:
47 
49 
51 
53 
55 
57 
59 
61 
63 
64 
65 public:
66 
68  {
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 
93  {
94  return m_manifoldsPtr.size()? &m_manifoldsPtr[0] : 0;
95  }
96 
98  {
99  return m_manifoldsPtr[index];
100  }
101 
103  {
104  return m_manifoldsPtr[index];
105  }
106 
107  btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration);
108 
109  virtual ~btCollisionDispatcher();
110 
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 
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  {
155  m_collisionConfiguration = config;
156  }
157 
159  {
161  }
162 
164  {
166  }
167 
168 };
169 
170 #endif //BT_COLLISION__DISPATCHER_H
171 
void setDispatcherFlags(int flags)
btCollisionConfiguration * m_collisionConfiguration
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
void(* btNearCallback)(btBroadphasePair &collisionPair, btCollisionDispatcher &dispatcher, const btDispatcherInfo &dispatchInfo)
user can override this nearcallback for collision filtering and more finegrained control over collisi...
btPersistentManifold * getManifoldByIndexInternal(int index)
void registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
registerCollisionCreateFunc allows registration of custom/alternative collision create functions ...
btCollisionConfiguration * getCollisionConfiguration()
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
btCollisionConfiguration allows to configure Bullet collision detection stack allocator size...
btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs...
virtual void freeCollisionAlgorithm(void *ptr)
btManifoldResult is a helper class to manage contact results.
void setNearCallback(btNearCallback nearCallback)
virtual void releaseManifold(btPersistentManifold *manifold)
The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
void setCollisionConfiguration(btCollisionConfiguration *config)
virtual bool needsCollision(const btCollisionObject *body0, const btCollisionObject *body1)
static void defaultNearCallback(btBroadphasePair &collisionPair, btCollisionDispatcher &dispatcher, const btDispatcherInfo &dispatchInfo)
btCollisionAlgorithmCreateFunc * m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]
int size() const
return the number of elements in the array
btManifoldResult m_defaultManifoldResult
btCollisionAlgorithm * findAlgorithm(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, btPersistentManifold *sharedManifold=0)
btAlignedObjectArray< btPersistentManifold * > m_manifoldsPtr
Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm.
const btPersistentManifold * getManifoldByIndexInternal(int index) const
btCollisionObject can be used to manage collision detection objects.
virtual void clearManifold(btPersistentManifold *manifold)
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:29
virtual btPersistentManifold * getNewManifold(const btCollisionObject *b0, const btCollisionObject *b1)
virtual const btPoolAllocator * getInternalManifoldPool() const
btCollisionDispatcher(btCollisionConfiguration *collisionConfiguration)
The btPoolAllocator class allows to efficiently allocate a large pool of objects, instead of dynamica...
virtual void dispatchAllCollisionPairs(btOverlappingPairCache *pairCache, const btDispatcherInfo &dispatchInfo, btDispatcher *dispatcher)
const btCollisionConfiguration * getCollisionConfiguration() const
btPoolAllocator * m_collisionAlgorithmPoolAllocator
virtual bool needsResponse(const btCollisionObject *body0, const btCollisionObject *body1)
virtual void * allocateCollisionAlgorithm(int size)
btNearCallback getNearCallback() const
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:69
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
btPoolAllocator * m_persistentManifoldPoolAllocator
virtual btPoolAllocator * getInternalManifoldPool()
btPersistentManifold ** getInternalManifoldPointer()
The btBroadphasePair class contains a pair of aabb-overlapping objects.