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

Bullet Collision Detection & Physics Library

btMultiSapBroadphase.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 #ifndef BT_MULTI_SAP_BROADPHASE
16 #define BT_MULTI_SAP_BROADPHASE
17
18 #include "btBroadphaseInterface.h"
19 #include "LinearMath/btAlignedObjectArray.h"
20 #include "btOverlappingPairCache.h"
21
22
23 class btBroadphaseInterface;
24 class btSimpleBroadphase;
25
26
27 typedef btAlignedObjectArray<btBroadphaseInterface*> btSapBroadphaseArray;
28
35 class btMultiSapBroadphase :public btBroadphaseInterface
36 {
37 btSapBroadphaseArray m_sapBroadphases;
38
39 btSimpleBroadphase* m_simpleBroadphase;
40
41 btOverlappingPairCache* m_overlappingPairs;
42
43 class btQuantizedBvh* m_optimizedAabbTree;
44
45
46 bool m_ownsPairCache;
47
48 btOverlapFilterCallback* m_filterCallback;
49
50 int m_invalidPair;
51
52 struct btBridgeProxy
53 {
54 btBroadphaseProxy* m_childProxy;
55 btBroadphaseInterface* m_childBroadphase;
56 };
57
58
59 public:
60
61 struct btMultiSapProxy : public btBroadphaseProxy
62 {
63
65 btAlignedObjectArray<btBridgeProxy*> m_bridgeProxies;
66 btVector3 m_aabbMin;
67 btVector3 m_aabbMax;
68
69 int m_shapeType;
70
71 /* void* m_userPtr;
72 short int m_collisionFilterGroup;
73 short int m_collisionFilterMask;
74 */
75 btMultiSapProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask)
76 :btBroadphaseProxy(aabbMin,aabbMax,userPtr,collisionFilterGroup,collisionFilterMask),
77 m_aabbMin(aabbMin),
78 m_aabbMax(aabbMax),
79 m_shapeType(shapeType)
80 {
81 m_multiSapParentProxy =this;
82 }
83
84
85 };
86
87 protected:
88
89
90 btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
91
92 public:
93
94 btMultiSapBroadphase(int maxProxies = 16384,btOverlappingPairCache* pairCache=0);
95
96
97 btSapBroadphaseArray& getBroadphaseArray()
98 {
99 return m_sapBroadphases;
100 }
101
102 const btSapBroadphaseArray& getBroadphaseArray() const
103 {
104 return m_sapBroadphases;
105 }
106
107 virtual ~btMultiSapBroadphase();
108
109 virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* multiSapProxy);
110 virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
111 virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax, btDispatcher* dispatcher);
112 virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, btVector3& aabbMax ) const;
113
114 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));
115
116 void addToChildBroadphase(btMultiSapProxy* parentMultiSapProxy, btBroadphaseProxy* childProxy, btBroadphaseInterface* childBroadphase);
117
119 virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
120
121 bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
122
123 virtual btOverlappingPairCache* getOverlappingPairCache()
124 {
125 return m_overlappingPairs;
126 }
127 virtual const btOverlappingPairCache* getOverlappingPairCache() const
128 {
129 return m_overlappingPairs;
130 }
131
134 virtual void getBroadphaseAabb(btVector3& aabbMin,btVector3& aabbMax) const
135 {
136 aabbMin.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
137 aabbMax.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
138 }
139
140 void buildTree(const btVector3& bvhAabbMin,const btVector3& bvhAabbMax);
141
142 virtual void printStats();
143
144 void quicksort (btBroadphasePairArray& a, int lo, int hi);
145
147 virtual void resetPool(btDispatcher* dispatcher);
148
149 };
150
151 #endif //BT_MULTI_SAP_BROADPHASE
btMultiSapBroadphase::btMultiSapProxy::m_shapeType
int m_shapeType
Definition: btMultiSapBroadphase.h:69
btOverlapFilterCallback
Definition: btOverlappingPairCache.h:38
btMultiSapBroadphase::btMultiSapProxy::btMultiSapProxy
btMultiSapProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, int shapeType, void *userPtr, short int collisionFilterGroup, short int collisionFilterMask)
Definition: btMultiSapBroadphase.h:75
BT_LARGE_FLOAT
#define BT_LARGE_FLOAT
Definition: btScalar.h:281
btMultiSapBroadphase::m_optimizedAabbTree
class btQuantizedBvh * m_optimizedAabbTree
Definition: btMultiSapBroadphase.h:43
btVector3::setValue
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
Definition: btVector3.h:650
btMultiSapBroadphase::m_overlappingPairs
btOverlappingPairCache * m_overlappingPairs
Definition: btMultiSapBroadphase.h:41
btAlignedObjectArray< btBroadphaseInterface * >
btMultiSapBroadphase
The btMultiSapBroadphase is a research project, not recommended to use in production.
Definition: btMultiSapBroadphase.h:35
btMultiSapBroadphase::btMultiSapProxy::m_aabbMin
btVector3 m_aabbMin
Definition: btMultiSapBroadphase.h:66
btMultiSapBroadphase::~btMultiSapBroadphase
virtual ~btMultiSapBroadphase()
Definition: btMultiSapBroadphase.cpp:78
btBroadphaseInterface.h
btMultiSapBroadphase::getBroadphaseAabb
virtual void getBroadphaseAabb(btVector3 &aabbMin, btVector3 &aabbMax) const
getAabb returns the axis aligned bounding box in the &#39;global&#39; coordinate frame will add some transfor...
Definition: btMultiSapBroadphase.h:134
btOverlappingPairCache.h
btOverlappingPairCache
The btOverlappingPairCache provides an interface for overlapping pair management (add, remove, storage), used by the btBroadphaseInterface broadphases.
Definition: btOverlappingPairCache.h:60
btMultiSapBroadphase::btBridgeProxy::m_childProxy
btBroadphaseProxy * m_childProxy
Definition: btMultiSapBroadphase.h:54
btMultiSapBroadphase::getBroadphaseArray
const btSapBroadphaseArray & getBroadphaseArray() const
Definition: btMultiSapBroadphase.h:102
btMultiSapBroadphase::printStats
virtual void printStats()
Definition: btMultiSapBroadphase.cpp:467
btMultiSapBroadphase::resetPool
virtual void resetPool(btDispatcher *dispatcher)
reset broadphase internal structures, to ensure determinism/reproducability
Definition: btMultiSapBroadphase.cpp:486
btMultiSapBroadphase::m_filterCallback
btOverlapFilterCallback * m_filterCallback
Definition: btMultiSapBroadphase.h:48
btMultiSapBroadphase::testAabbOverlap
bool testAabbOverlap(btBroadphaseProxy *proxy0, btBroadphaseProxy *proxy1)
Definition: btMultiSapBroadphase.cpp:456
btBroadphaseRayCallback
Definition: btBroadphaseInterface.h:36
btMultiSapBroadphase::addToChildBroadphase
void addToChildBroadphase(btMultiSapProxy *parentMultiSapProxy, btBroadphaseProxy *childProxy, btBroadphaseInterface *childBroadphase)
Definition: btMultiSapBroadphase.cpp:128
btMultiSapBroadphase::getBroadphaseArray
btSapBroadphaseArray & getBroadphaseArray()
Definition: btMultiSapBroadphase.h:97
btMultiSapBroadphase::getOverlappingPairCache
virtual btOverlappingPairCache * getOverlappingPairCache()
Definition: btMultiSapBroadphase.h:123
btMultiSapBroadphase::createProxy
virtual btBroadphaseProxy * createProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, int shapeType, void *userPtr, short int collisionFilterGroup, short int collisionFilterMask, btDispatcher *dispatcher, void *multiSapProxy)
Definition: btMultiSapBroadphase.cpp:107
btMultiSapBroadphase::getAabb
virtual void getAabb(btBroadphaseProxy *proxy, btVector3 &aabbMin, btVector3 &aabbMax) const
Definition: btMultiSapBroadphase.cpp:152
btMultiSapBroadphase::btMultiSapBroadphase
btMultiSapBroadphase(int maxProxies=16384, btOverlappingPairCache *pairCache=0)
Definition: btMultiSapBroadphase.cpp:40
btBroadphaseInterface
The btBroadphaseInterface class provides an interface to detect aabb-overlapping object pairs...
Definition: btBroadphaseInterface.h:51
btMultiSapBroadphase::quicksort
void quicksort(btBroadphasePairArray &a, int lo, int hi)
btMultiSapBroadphase::m_ownsPairCache
bool m_ownsPairCache
Definition: btMultiSapBroadphase.h:46
btBroadphaseProxy
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
Definition: btBroadphaseProxy.h:85
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
btMultiSapBroadphase::btMultiSapProxy
Definition: btMultiSapBroadphase.h:61
btMultiSapBroadphase::m_invalidPair
int m_invalidPair
Definition: btMultiSapBroadphase.h:50
btMultiSapBroadphase::m_sapBroadphases
btSapBroadphaseArray m_sapBroadphases
Definition: btMultiSapBroadphase.h:37
btMultiSapBroadphase::m_multiSapProxies
btAlignedObjectArray< btMultiSapProxy * > m_multiSapProxies
Definition: btMultiSapBroadphase.h:90
btSimpleBroadphase
The SimpleBroadphase is just a unit-test for btAxisSweep3, bt32BitAxisSweep3, or btDbvtBroadphase, so use those classes instead.
Definition: btSimpleBroadphase.h:49
btMultiSapBroadphase::btBridgeProxy::m_childBroadphase
btBroadphaseInterface * m_childBroadphase
Definition: btMultiSapBroadphase.h:55
btMultiSapBroadphase::btMultiSapProxy::m_bridgeProxies
btAlignedObjectArray< btBridgeProxy * > m_bridgeProxies
array with all the entries that this proxy belongs to
Definition: btMultiSapBroadphase.h:65
btQuantizedBvh
The btQuantizedBvh class stores an AABB tree that can be quickly traversed on CPU and Cell SPU...
Definition: btQuantizedBvh.h:174
btMultiSapBroadphase::setAabb
virtual void setAabb(btBroadphaseProxy *proxy, const btVector3 &aabbMin, const btVector3 &aabbMax, btDispatcher *dispatcher)
Definition: btMultiSapBroadphase.cpp:170
btAlignedObjectArray.h
btSapBroadphaseArray
btAlignedObjectArray< btBroadphaseInterface * > btSapBroadphaseArray
Definition: btMultiSapBroadphase.h:24
btMultiSapBroadphase::m_simpleBroadphase
btSimpleBroadphase * m_simpleBroadphase
Definition: btMultiSapBroadphase.h:39
btMultiSapBroadphase::destroyProxy
virtual void destroyProxy(btBroadphaseProxy *proxy, btDispatcher *dispatcher)
Definition: btMultiSapBroadphase.cpp:120
btMultiSapBroadphase::rayTest
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))
Definition: btMultiSapBroadphase.cpp:159
btMultiSapBroadphase::getOverlappingPairCache
virtual const btOverlappingPairCache * getOverlappingPairCache() const
Definition: btMultiSapBroadphase.h:127
btMultiSapBroadphase::btBridgeProxy
Definition: btMultiSapBroadphase.h:52
btDispatcher
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:69
btMultiSapBroadphase::buildTree
void buildTree(const btVector3 &bvhAabbMin, const btVector3 &bvhAabbMax)
Definition: btMultiSapBroadphase.cpp:88
btMultiSapBroadphase::calculateOverlappingPairs
virtual void calculateOverlappingPairs(btDispatcher *dispatcher)
calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during th...
Definition: btMultiSapBroadphase.cpp:359
btMultiSapBroadphase::btMultiSapProxy::m_aabbMax
btVector3 m_aabbMax
Definition: btMultiSapBroadphase.h:67