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

Bullet Collision Detection & Physics Library

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

btBroadphaseProxy.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_BROADPHASE_PROXY_H
17 #define BT_BROADPHASE_PROXY_H
18
19 #include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE
20 #include "LinearMath/btVector3.h"
21 #include "LinearMath/btAlignedAllocator.h"
22
23
28 enum BroadphaseNativeTypes
29 {
30 // polyhedral convex shapes
31 BOX_SHAPE_PROXYTYPE,
32 TRIANGLE_SHAPE_PROXYTYPE,
33 TETRAHEDRAL_SHAPE_PROXYTYPE,
34 CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
35 CONVEX_HULL_SHAPE_PROXYTYPE,
36 CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
37 CUSTOM_POLYHEDRAL_SHAPE_TYPE,
38 //implicit convex shapes
39 IMPLICIT_CONVEX_SHAPES_START_HERE,
40 SPHERE_SHAPE_PROXYTYPE,
41 MULTI_SPHERE_SHAPE_PROXYTYPE,
42 CAPSULE_SHAPE_PROXYTYPE,
43 CONE_SHAPE_PROXYTYPE,
44 CONVEX_SHAPE_PROXYTYPE,
45 CYLINDER_SHAPE_PROXYTYPE,
46 UNIFORM_SCALING_SHAPE_PROXYTYPE,
47 MINKOWSKI_SUM_SHAPE_PROXYTYPE,
48 MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
49 BOX_2D_SHAPE_PROXYTYPE,
50 CONVEX_2D_SHAPE_PROXYTYPE,
51 CUSTOM_CONVEX_SHAPE_TYPE,
52 //concave shapes
53 CONCAVE_SHAPES_START_HERE,
54 //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
55 TRIANGLE_MESH_SHAPE_PROXYTYPE,
56 SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
58 FAST_CONCAVE_MESH_PROXYTYPE,
59 //terrain
60 TERRAIN_SHAPE_PROXYTYPE,
62 GIMPACT_SHAPE_PROXYTYPE,
64 MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
65
66 EMPTY_SHAPE_PROXYTYPE,
67 STATIC_PLANE_PROXYTYPE,
68 CUSTOM_CONCAVE_SHAPE_TYPE,
69 CONCAVE_SHAPES_END_HERE,
70
71 COMPOUND_SHAPE_PROXYTYPE,
72
73 SOFTBODY_SHAPE_PROXYTYPE,
74 HFFLUID_SHAPE_PROXYTYPE,
75 HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE,
76 INVALID_SHAPE_PROXYTYPE,
77
78 MAX_BROADPHASE_COLLISION_TYPES
79
80 };
81
82
85 ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy
86 {
87
88 BT_DECLARE_ALIGNED_ALLOCATOR();
89
91 enum CollisionFilterGroups
92 {
93 DefaultFilter = 1,
94 StaticFilter = 2,
95 KinematicFilter = 4,
96 DebrisFilter = 8,
97 SensorTrigger = 16,
98 CharacterFilter = 32,
99 AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
100 };
101
102 //Usually the client btCollisionObject or Rigidbody class
103 void* m_clientObject;
104 short int m_collisionFilterGroup;
105 short int m_collisionFilterMask;
106 void* m_multiSapParentProxy;
107 int m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
108
109 btVector3 m_aabbMin;
110 btVector3 m_aabbMax;
111
112 SIMD_FORCE_INLINE int getUid() const
113 {
114 return m_uniqueId;
115 }
116
117 //used for memory pools
118 btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
119 {
120 }
121
122 btBroadphaseProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
123 :m_clientObject(userPtr),
124 m_collisionFilterGroup(collisionFilterGroup),
125 m_collisionFilterMask(collisionFilterMask),
126 m_aabbMin(aabbMin),
127 m_aabbMax(aabbMax)
128 {
129 m_multiSapParentProxy = multiSapParentProxy;
130 }
131
132
133
134 static SIMD_FORCE_INLINE bool isPolyhedral(int proxyType)
135 {
136 return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE);
137 }
138
139 static SIMD_FORCE_INLINE bool isConvex(int proxyType)
140 {
141 return (proxyType < CONCAVE_SHAPES_START_HERE);
142 }
143
144 static SIMD_FORCE_INLINE bool isNonMoving(int proxyType)
145 {
146 return (isConcave(proxyType) && !(proxyType==GIMPACT_SHAPE_PROXYTYPE));
147 }
148
149 static SIMD_FORCE_INLINE bool isConcave(int proxyType)
150 {
151 return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
152 (proxyType < CONCAVE_SHAPES_END_HERE));
153 }
154 static SIMD_FORCE_INLINE bool isCompound(int proxyType)
155 {
156 return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
157 }
158
159 static SIMD_FORCE_INLINE bool isSoftBody(int proxyType)
160 {
161 return (proxyType == SOFTBODY_SHAPE_PROXYTYPE);
162 }
163
164 static SIMD_FORCE_INLINE bool isInfinite(int proxyType)
165 {
166 return (proxyType == STATIC_PLANE_PROXYTYPE);
167 }
168
169 static SIMD_FORCE_INLINE bool isConvex2d(int proxyType)
170 {
171 return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE);
172 }
173
174
175 }
176 ;
177
178 class btCollisionAlgorithm;
179
180 struct btBroadphaseProxy;
181
182
183
186 ATTRIBUTE_ALIGNED16(struct) btBroadphasePair
187 {
188 btBroadphasePair ()
189 :
190 m_pProxy0(0),
191 m_pProxy1(0),
192 m_algorithm(0),
193 m_internalInfo1(0)
194 {
195 }
196
197 BT_DECLARE_ALIGNED_ALLOCATOR();
198
199 btBroadphasePair(const btBroadphasePair& other)
200 : m_pProxy0(other.m_pProxy0),
201 m_pProxy1(other.m_pProxy1),
202 m_algorithm(other.m_algorithm),
203 m_internalInfo1(other.m_internalInfo1)
204 {
205 }
206 btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
207 {
208
209 //keep them sorted, so the std::set operations work
210 if (proxy0.m_uniqueId < proxy1.m_uniqueId)
211 {
212 m_pProxy0 = &proxy0;
213 m_pProxy1 = &proxy1;
214 }
215 else
216 {
217 m_pProxy0 = &proxy1;
218 m_pProxy1 = &proxy0;
219 }
220
221 m_algorithm = 0;
222 m_internalInfo1 = 0;
223
224 }
225
226 btBroadphaseProxy* m_pProxy0;
227 btBroadphaseProxy* m_pProxy1;
228
229 mutable btCollisionAlgorithm* m_algorithm;
230 union { void* m_internalInfo1; int m_internalTmpValue;};//don't use this data, it will be removed in future version.
231
232 };
233
234 /*
235 //comparison for set operation, see Solid DT_Encounter
236 SIMD_FORCE_INLINE bool operator<(const btBroadphasePair& a, const btBroadphasePair& b)
237 {
238 return a.m_pProxy0 < b.m_pProxy0 ||
239 (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1);
240 }
241 */
242
243
244
245 class btBroadphasePairSortPredicate
246 {
247 public:
248
249 bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) const
250 {
251 const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
252 const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
253 const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
254 const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
255
256 return uidA0 > uidB0 ||
257 (a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
258 (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
259 }
260 };
261
262
263 SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b)
264 {
265 return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
266 }
267
268
269 #endif //BT_BROADPHASE_PROXY_H
270
SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:56
CONCAVE_SHAPES_START_HERE
Definition: btBroadphaseProxy.h:53
CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:36
MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:48
CONE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:43
btBroadphaseProxy::m_multiSapParentProxy
void * m_multiSapParentProxy
Definition: btBroadphaseProxy.h:106
btBroadphasePair::btBroadphasePair
btBroadphasePair(const btBroadphasePair &other)
Definition: btBroadphaseProxy.h:199
SPHERE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:40
SOFTBODY_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:73
btBroadphaseProxy::isInfinite
static bool isInfinite(int proxyType)
Definition: btBroadphaseProxy.h:164
HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:75
btVector3.h
IMPLICIT_CONVEX_SHAPES_START_HERE
Definition: btBroadphaseProxy.h:39
btBroadphaseProxy::m_collisionFilterGroup
short int m_collisionFilterGroup
Definition: btBroadphaseProxy.h:104
btBroadphaseProxy::m_aabbMax
btVector3 m_aabbMax
Definition: btBroadphaseProxy.h:110
MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE
Multimaterial mesh.
Definition: btBroadphaseProxy.h:64
CAPSULE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:42
TRIANGLE_MESH_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:55
CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:34
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition: btScalar.h:63
btBroadphaseProxy::isCompound
static bool isCompound(int proxyType)
Definition: btBroadphaseProxy.h:154
btBroadphasePairSortPredicate::operator()
bool operator()(const btBroadphasePair &a, const btBroadphasePair &b) const
Definition: btBroadphaseProxy.h:249
btAlignedAllocator.h
BOX_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:31
GIMPACT_SHAPE_PROXYTYPE
Used for GIMPACT Trimesh integration.
Definition: btBroadphaseProxy.h:62
btBroadphaseProxy::isNonMoving
static bool isNonMoving(int proxyType)
Definition: btBroadphaseProxy.h:144
UNIFORM_SCALING_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:46
MINKOWSKI_SUM_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:47
CYLINDER_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:45
INVALID_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:76
TRIANGLE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:32
BOX_2D_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:49
MULTI_SPHERE_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:41
btBroadphasePair::m_internalTmpValue
int m_internalTmpValue
Definition: btBroadphaseProxy.h:230
btBroadphasePair::btBroadphasePair
btBroadphasePair()
Definition: btBroadphaseProxy.h:188
TETRAHEDRAL_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:33
btBroadphaseProxy::m_clientObject
void * m_clientObject
Definition: btBroadphaseProxy.h:103
MAX_BROADPHASE_COLLISION_TYPES
Definition: btBroadphaseProxy.h:78
btBroadphaseProxy
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
Definition: btBroadphaseProxy.h:85
btBroadphasePair::m_pProxy1
btBroadphaseProxy * m_pProxy1
Definition: btBroadphaseProxy.h:227
btBroadphasePair::m_algorithm
btCollisionAlgorithm * m_algorithm
Definition: btBroadphaseProxy.h:229
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:64
btBroadphaseProxy::isPolyhedral
static bool isPolyhedral(int proxyType)
Definition: btBroadphaseProxy.h:134
btBroadphasePair::m_pProxy0
btBroadphaseProxy * m_pProxy0
Definition: btBroadphaseProxy.h:226
btBroadphaseProxy::isSoftBody
static bool isSoftBody(int proxyType)
Definition: btBroadphaseProxy.h:159
btBroadphaseProxy::m_aabbMin
btVector3 m_aabbMin
Definition: btBroadphaseProxy.h:109
CONVEX_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:44
BroadphaseNativeTypes
BroadphaseNativeTypes
btDispatcher uses these types IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and co...
Definition: btBroadphaseProxy.h:28
CUSTOM_CONCAVE_SHAPE_TYPE
Definition: btBroadphaseProxy.h:68
CUSTOM_POLYHEDRAL_SHAPE_TYPE
Definition: btBroadphaseProxy.h:37
btBroadphasePair::btBroadphasePair
btBroadphasePair(btBroadphaseProxy &proxy0, btBroadphaseProxy &proxy1)
Definition: btBroadphaseProxy.h:206
TERRAIN_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:60
CONVEX_HULL_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:35
btBroadphasePairSortPredicate
Definition: btBroadphaseProxy.h:245
btBroadphaseProxy::m_uniqueId
int m_uniqueId
Definition: btBroadphaseProxy.h:107
BT_DECLARE_ALIGNED_ALLOCATOR
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:388
operator==
bool operator==(const btBroadphasePair &a, const btBroadphasePair &b)
Definition: btBroadphaseProxy.h:263
btBroadphaseProxy::isConvex2d
static bool isConvex2d(int proxyType)
Definition: btBroadphaseProxy.h:169
btBroadphaseProxy::isConcave
static bool isConcave(int proxyType)
Definition: btBroadphaseProxy.h:149
CUSTOM_CONVEX_SHAPE_TYPE
Definition: btBroadphaseProxy.h:51
HFFLUID_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:74
btBroadphaseProxy::m_collisionFilterMask
short int m_collisionFilterMask
Definition: btBroadphaseProxy.h:105
EMPTY_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:66
COMPOUND_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:71
btBroadphaseProxy::btBroadphaseProxy
btBroadphaseProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, void *userPtr, short int collisionFilterGroup, short int collisionFilterMask, void *multiSapParentProxy=0)
Definition: btBroadphaseProxy.h:122
btBroadphaseProxy::CollisionFilterGroups
CollisionFilterGroups
optional filtering to cull potential collisions
Definition: btBroadphaseProxy.h:91
btBroadphaseProxy::getUid
int getUid() const
Definition: btBroadphaseProxy.h:112
btCollisionAlgorithm
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
Definition: btCollisionAlgorithm.h:55
CONVEX_2D_SHAPE_PROXYTYPE
Definition: btBroadphaseProxy.h:50
btBroadphaseProxy::isConvex
static bool isConvex(int proxyType)
Definition: btBroadphaseProxy.h:139
CONCAVE_SHAPES_END_HERE
Definition: btBroadphaseProxy.h:69
FAST_CONCAVE_MESH_PROXYTYPE
used for demo integration FAST/Swift collision library and Bullet
Definition: btBroadphaseProxy.h:58
STATIC_PLANE_PROXYTYPE
Definition: btBroadphaseProxy.h:67
btScalar.h
btBroadphaseProxy::btBroadphaseProxy
btBroadphaseProxy()
Definition: btBroadphaseProxy.h:118
btBroadphasePair
The btBroadphasePair class contains a pair of aabb-overlapping objects.
Definition: btBroadphaseProxy.h:186