Bullet Collision Detection & Physics Library
btSimpleBroadphase.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_SIMPLE_BROADPHASE_H
17 #define BT_SIMPLE_BROADPHASE_H
18 
19 
20 #include "btOverlappingPairCache.h"
21 
22 
24 {
26 
27 // int m_handleId;
28 
29 
31 
32  btSimpleBroadphaseProxy(const btVector3& minpt,const btVector3& maxpt,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask,void* multiSapProxy)
33  :btBroadphaseProxy(minpt,maxpt,userPtr,collisionFilterGroup,collisionFilterMask,multiSapProxy)
34  {
35  (void)shapeType;
36  }
37 
38 
39  SIMD_FORCE_INLINE void SetNextFree(int next) {m_nextFree = next;}
41 
42 
43 
44 
45 };
46 
50 {
51 
52 protected:
53 
54  int m_numHandles; // number of active handles
55  int m_maxHandles; // max number of handles
57 
59 
61  int m_firstFreeHandle; // free handles list
62 
64  {
68  m_numHandles++;
69  if(freeHandle > m_LastHandleIndex)
70  {
72  }
73  return freeHandle;
74  }
75 
77  {
78  int handle = int(proxy-m_pHandles);
79  btAssert(handle >= 0 && handle < m_maxHandles);
80  if(handle == m_LastHandleIndex)
81  {
83  }
85  m_firstFreeHandle = handle;
86 
87  proxy->m_clientObject = 0;
88 
89  m_numHandles--;
90  }
91 
94 
96 
97 
98 
100  {
101  btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy);
102  return proxy0;
103  }
104 
106  {
107  const btSimpleBroadphaseProxy* proxy0 = static_cast<const btSimpleBroadphaseProxy*>(proxy);
108  return proxy0;
109  }
110 
112  virtual void resetPool(btDispatcher* dispatcher);
113 
114 
115  void validate();
116 
117 protected:
118 
119 
120 
121 
122 public:
123  btSimpleBroadphase(int maxProxies=16384,btOverlappingPairCache* overlappingPairCache=0);
124  virtual ~btSimpleBroadphase();
125 
126 
127  static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1);
128 
129 
130  virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
131 
132  virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
133 
134  virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
135  virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
136  virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
137 
138  virtual void rayTest(const btVector3& rayFrom,const btVector3& rayTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVector3(0,0,0),const btVector3& aabbMax=btVector3(0,0,0));
139  virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
140 
142  {
143  return m_pairCache;
144  }
146  {
147  return m_pairCache;
148  }
149 
151 
152 
155  virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
156  {
159  }
160 
161  virtual void printStats()
162  {
163 // printf("btSimpleBroadphase.h\n");
164 // printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
165  }
166 };
167 
168 
169 
170 #endif //BT_SIMPLE_BROADPHASE_H
171 
btSimpleBroadphaseProxy * m_pHandles
#define BT_LARGE_FLOAT
Definition: btScalar.h:268
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
void freeHandle(btSimpleBroadphaseProxy *proxy)
btSimpleBroadphaseProxy * getSimpleProxyFromProxy(btBroadphaseProxy *proxy)
#define btAssert(x)
Definition: btScalar.h:101
static bool aabbOverlap(btSimpleBroadphaseProxy *proxy0, btSimpleBroadphaseProxy *proxy1)
#define SIMD_FORCE_INLINE
Definition: btScalar.h:58
virtual void destroyProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)
virtual void resetPool(btDispatcher *dispatcher)
reset broadphase internal structures, to ensure determinism/reproducability
The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
btOverlappingPairCache * m_pairCache
virtual btBroadphaseProxy * createProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, int shapeType, void *userPtr, short int collisionFilterGroup, short int collisionFilterMask, btDispatcher *dispatcher, void *multiSapProxy)
virtual void rayTest(const btVector3 &rayFrom, const btVector3 &rayTo, btBroadphaseRayCallback &rayCallback, const btVector3 &aabbMin=btVector3(0, 0, 0), const btVector3 &aabbMax=btVector3(0, 0, 0))
btSimpleBroadphaseProxy(const btVector3 &minpt, const btVector3 &maxpt, int shapeType, void *userPtr, short int collisionFilterGroup, short int collisionFilterMask, void *multiSapProxy)
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
virtual void getAabb(btBroadphaseProxy *proxy, btVector3 &aabbMin, btVector3 &aabbMax) const
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
bool testAabbOverlap(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
virtual void printStats()
The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase, so use those classes instead.
virtual void aabbTest(const btVector3 &aabbMin, const btVector3 &aabbMax, btBroadphaseAabbCallback &callback)
virtual void calculateOverlappingPairs(btDispatcher *dispatcher)
calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during th...
const btSimpleBroadphaseProxy * getSimpleProxyFromProxy(btBroadphaseProxy *proxy) const
btOverlappingPairCache * getOverlappingPairCache()
btSimpleBroadphase(int maxProxies=16384, btOverlappingPairCache *overlappingPairCache=0)
virtual void setAabb(btBroadphaseProxy *proxy, const btVector3 &aabbMin, const btVector3 &aabbMax, btDispatcher *dispatcher)
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:69
const btOverlappingPairCache * getOverlappingPairCache() const
virtual void getBroadphaseAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb returns the axis aligned bounding box in the 'global' coordinate frame will add some transfor...