Bullet Collision Detection & Physics Library
btSimpleBroadphase.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_SIMPLE_BROADPHASE_H
17#define BT_SIMPLE_BROADPHASE_H
18
20
22{
24
25 // int m_handleId;
26
28
29 btSimpleBroadphaseProxy(const btVector3& minpt, const btVector3& maxpt, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask)
30 : btBroadphaseProxy(minpt, maxpt, userPtr, collisionFilterGroup, collisionFilterMask)
31 {
32 (void)shapeType;
33 }
34
35 SIMD_FORCE_INLINE void SetNextFree(int next) { m_nextFree = next; }
37};
38
42{
43protected:
44 int m_numHandles; // number of active handles
45 int m_maxHandles; // max number of handles
47
49
51 int m_firstFreeHandle; // free handles list
52
54 {
60 {
62 }
63 return freeHandle;
64 }
65
67 {
68 int handle = int(proxy - m_pHandles);
69 btAssert(handle >= 0 && handle < m_maxHandles);
70 if (handle == m_LastHandleIndex)
71 {
73 }
75 m_firstFreeHandle = handle;
76
77 proxy->m_clientObject = 0;
78
80 }
81
84
86
88 {
89 btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy);
90 return proxy0;
91 }
92
94 {
95 const btSimpleBroadphaseProxy* proxy0 = static_cast<const btSimpleBroadphaseProxy*>(proxy);
96 return proxy0;
97 }
98
100 virtual void resetPool(btDispatcher* dispatcher);
101
102 void validate();
103
104protected:
105public:
106 btSimpleBroadphase(int maxProxies = 16384, btOverlappingPairCache* overlappingPairCache = 0);
107 virtual ~btSimpleBroadphase();
108
109 static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0, btSimpleBroadphaseProxy* proxy1);
110
111 virtual btBroadphaseProxy* createProxy(const btVector3& aabbMin, const btVector3& aabbMax, int shapeType, void* userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher* dispatcher);
112
113 virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
114
115 virtual void destroyProxy(btBroadphaseProxy* proxy, btDispatcher* dispatcher);
116 virtual void setAabb(btBroadphaseProxy* proxy, const btVector3& aabbMin, const btVector3& aabbMax, btDispatcher* dispatcher);
117 virtual void getAabb(btBroadphaseProxy* proxy, btVector3& aabbMin, btVector3& aabbMax) const;
118
119 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));
120 virtual void aabbTest(const btVector3& aabbMin, const btVector3& aabbMax, btBroadphaseAabbCallback& callback);
121
123 {
124 return m_pairCache;
125 }
127 {
128 return m_pairCache;
129 }
130
132
135 virtual void getBroadphaseAabb(btVector3& aabbMin, btVector3& aabbMax) const
136 {
139 }
140
141 virtual void printStats()
142 {
143 // printf("btSimpleBroadphase.h\n");
144 // printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
145 }
146};
147
148#endif //BT_SIMPLE_BROADPHASE_H
#define BT_LARGE_FLOAT
Definition: btScalar.h:316
#define SIMD_FORCE_INLINE
Definition: btScalar.h:98
#define btAssert(x)
Definition: btScalar.h:153
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs.
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:77
The btOverlappingPairCache provides an interface for overlapping pair management (add,...
The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase,...
virtual void aabbTest(const btVector3 &aabbMin, const btVector3 &aabbMax, btBroadphaseAabbCallback &callback)
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))
const btOverlappingPairCache * getOverlappingPairCache() const
bool testAabbOverlap(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
void freeHandle(btSimpleBroadphaseProxy *proxy)
btOverlappingPairCache * m_pairCache
virtual void getBroadphaseAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb returns the axis aligned bounding box in the 'global' coordinate frame will add some transfor...
virtual void resetPool(btDispatcher *dispatcher)
reset broadphase internal structures, to ensure determinism/reproducability
virtual void setAabb(btBroadphaseProxy *proxy, const btVector3 &aabbMin, const btVector3 &aabbMax, btDispatcher *dispatcher)
const btSimpleBroadphaseProxy * getSimpleProxyFromProxy(btBroadphaseProxy *proxy) const
virtual btBroadphaseProxy * createProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, int shapeType, void *userPtr, int collisionFilterGroup, int collisionFilterMask, btDispatcher *dispatcher)
virtual void printStats()
btSimpleBroadphaseProxy * m_pHandles
btSimpleBroadphase(int maxProxies=16384, btOverlappingPairCache *overlappingPairCache=0)
virtual void getAabb(btBroadphaseProxy *proxy, btVector3 &aabbMin, btVector3 &aabbMax) const
virtual void destroyProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)
virtual void calculateOverlappingPairs(btDispatcher *dispatcher)
calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during th...
btSimpleBroadphaseProxy * getSimpleProxyFromProxy(btBroadphaseProxy *proxy)
static bool aabbOverlap(btSimpleBroadphaseProxy *proxy0, btSimpleBroadphaseProxy *proxy1)
btOverlappingPairCache * getOverlappingPairCache()
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:82
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:640
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
btSimpleBroadphaseProxy(const btVector3 &minpt, const btVector3 &maxpt, int shapeType, void *userPtr, int collisionFilterGroup, int collisionFilterMask)