Bullet Collision Detection & Physics Library
btBroadphaseProxy.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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_BROADPHASE_PROXY_H
17#define BT_BROADPHASE_PROXY_H
18
19#include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE
22
23
29{
30 // polyhedral convex shapes
38//implicit convex shapes
52//concave shapes
54 //keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
59 //terrain
65
70
72
77
79
80};
81
82
86{
87
89
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
106
107 int m_uniqueId;//m_uniqueId is introduced for paircache. could get rid of this, by calculating the address offset etc.
108
111
113 {
114 return m_uniqueId;
115 }
116
117 //used for memory pools
118 btBroadphaseProxy() :m_clientObject(0)
119 {
120 }
121
122 btBroadphaseProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr, int collisionFilterGroup, int collisionFilterMask)
123 :m_clientObject(userPtr),
124 m_collisionFilterGroup(collisionFilterGroup),
125 m_collisionFilterMask(collisionFilterMask),
126 m_aabbMin(aabbMin),
127 m_aabbMax(aabbMax)
128 {
129 }
130
131
132
133 static SIMD_FORCE_INLINE bool isPolyhedral(int proxyType)
134 {
135 return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE);
136 }
137
138 static SIMD_FORCE_INLINE bool isConvex(int proxyType)
139 {
140 return (proxyType < CONCAVE_SHAPES_START_HERE);
141 }
142
143 static SIMD_FORCE_INLINE bool isNonMoving(int proxyType)
144 {
145 return (isConcave(proxyType) && !(proxyType==GIMPACT_SHAPE_PROXYTYPE));
146 }
147
148 static SIMD_FORCE_INLINE bool isConcave(int proxyType)
149 {
150 return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
151 (proxyType < CONCAVE_SHAPES_END_HERE));
152 }
153 static SIMD_FORCE_INLINE bool isCompound(int proxyType)
154 {
155 return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
156 }
157
158 static SIMD_FORCE_INLINE bool isSoftBody(int proxyType)
159 {
160 return (proxyType == SOFTBODY_SHAPE_PROXYTYPE);
161 }
162
163 static SIMD_FORCE_INLINE bool isInfinite(int proxyType)
164 {
165 return (proxyType == STATIC_PLANE_PROXYTYPE);
166 }
167
168 static SIMD_FORCE_INLINE bool isConvex2d(int proxyType)
169 {
170 return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE);
171 }
172
173
174}
175;
176
178
179struct btBroadphaseProxy;
180
181
182
186{
188 :
189 m_pProxy0(0),
190 m_pProxy1(0),
191 m_algorithm(0),
192 m_internalInfo1(0)
193 {
194 }
195
197
199 : m_pProxy0(other.m_pProxy0),
200 m_pProxy1(other.m_pProxy1),
201 m_algorithm(other.m_algorithm),
202 m_internalInfo1(other.m_internalInfo1)
203 {
204 }
206 {
207
208 //keep them sorted, so the std::set operations work
209 if (proxy0.m_uniqueId < proxy1.m_uniqueId)
210 {
211 m_pProxy0 = &proxy0;
212 m_pProxy1 = &proxy1;
213 }
214 else
215 {
216 m_pProxy0 = &proxy1;
217 m_pProxy1 = &proxy0;
218 }
219
220 m_algorithm = 0;
221 m_internalInfo1 = 0;
222
223 }
224
227
229 union { void* m_internalInfo1; int m_internalTmpValue;};//don't use this data, it will be removed in future version.
230
231};
232
233/*
234//comparison for set operation, see Solid DT_Encounter
235SIMD_FORCE_INLINE bool operator<(const btBroadphasePair& a, const btBroadphasePair& b)
236{
237 return a.m_pProxy0 < b.m_pProxy0 ||
238 (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 < b.m_pProxy1);
239}
240*/
241
242
243
245{
246 public:
247
248 bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b ) const
249 {
250 const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
251 const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
252 const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
253 const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
254
255 return uidA0 > uidB0 ||
256 (a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
257 (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
258 }
259};
260
261
263{
264 return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
265}
266
267
268#endif //BT_BROADPHASE_PROXY_H
269
BroadphaseNativeTypes
btDispatcher uses these types IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and co...
@ CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE
@ MINKOWSKI_SUM_SHAPE_PROXYTYPE
@ CUSTOM_POLYHEDRAL_SHAPE_TYPE
@ CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE
@ COMPOUND_SHAPE_PROXYTYPE
@ CONCAVE_SHAPES_START_HERE
@ IMPLICIT_CONVEX_SHAPES_START_HERE
@ HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE
@ GIMPACT_SHAPE_PROXYTYPE
Used for GIMPACT Trimesh integration.
@ SOFTBODY_SHAPE_PROXYTYPE
@ CONVEX_2D_SHAPE_PROXYTYPE
@ SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE
@ TRIANGLE_SHAPE_PROXYTYPE
@ TRIANGLE_MESH_SHAPE_PROXYTYPE
@ CONVEX_SHAPE_PROXYTYPE
@ TERRAIN_SHAPE_PROXYTYPE
@ MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE
Multimaterial mesh.
@ STATIC_PLANE_PROXYTYPE
@ CUSTOM_CONCAVE_SHAPE_TYPE
@ INVALID_SHAPE_PROXYTYPE
@ UNIFORM_SCALING_SHAPE_PROXYTYPE
@ MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE
@ CUSTOM_CONVEX_SHAPE_TYPE
@ SPHERE_SHAPE_PROXYTYPE
@ BOX_SHAPE_PROXYTYPE
@ MULTI_SPHERE_SHAPE_PROXYTYPE
@ CYLINDER_SHAPE_PROXYTYPE
@ FAST_CONCAVE_MESH_PROXYTYPE
used for demo integration FAST/Swift collision library and Bullet
@ CONE_SHAPE_PROXYTYPE
@ BOX_2D_SHAPE_PROXYTYPE
@ EMPTY_SHAPE_PROXYTYPE
@ MAX_BROADPHASE_COLLISION_TYPES
@ CAPSULE_SHAPE_PROXYTYPE
@ TETRAHEDRAL_SHAPE_PROXYTYPE
@ HFFLUID_SHAPE_PROXYTYPE
@ CONCAVE_SHAPES_END_HERE
@ CONVEX_HULL_SHAPE_PROXYTYPE
bool operator==(const btBroadphasePair &a, const btBroadphasePair &b)
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:82
#define SIMD_FORCE_INLINE
Definition: btScalar.h:81
bool operator()(const btBroadphasePair &a, const btBroadphasePair &b) const
btCollisionAlgorithm is an collision interface that is compatible with the Broadphase and btDispatche...
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:84
The btBroadphasePair class contains a pair of aabb-overlapping objects.
btBroadphasePair(btBroadphaseProxy &proxy0, btBroadphaseProxy &proxy1)
btBroadphaseProxy * m_pProxy1
btBroadphaseProxy * m_pProxy0
btBroadphasePair(const btBroadphasePair &other)
btCollisionAlgorithm * m_algorithm
The btBroadphaseProxy is the main class that can be used with the Bullet broadphases.
CollisionFilterGroups
optional filtering to cull potential collisions
static bool isInfinite(int proxyType)
static bool isCompound(int proxyType)
static bool isSoftBody(int proxyType)
static bool isConvex2d(int proxyType)
static bool isPolyhedral(int proxyType)
static bool isNonMoving(int proxyType)
static bool isConcave(int proxyType)
static bool isConvex(int proxyType)
btBroadphaseProxy(const btVector3 &aabbMin, const btVector3 &aabbMax, void *userPtr, int collisionFilterGroup, int collisionFilterMask)