00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BROADPHASE_PROXY_H
00017 #define BROADPHASE_PROXY_H
00018
00019 #include "LinearMath/btScalar.h"
00020 #include "LinearMath/btVector3.h"
00021 #include "LinearMath/btAlignedAllocator.h"
00022
00023
00028 enum BroadphaseNativeTypes
00029 {
00030
00031 BOX_SHAPE_PROXYTYPE,
00032 TRIANGLE_SHAPE_PROXYTYPE,
00033 TETRAHEDRAL_SHAPE_PROXYTYPE,
00034 CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
00035 CONVEX_HULL_SHAPE_PROXYTYPE,
00036 CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE,
00037 CUSTOM_POLYHEDRAL_SHAPE_TYPE,
00038
00039 IMPLICIT_CONVEX_SHAPES_START_HERE,
00040 SPHERE_SHAPE_PROXYTYPE,
00041 MULTI_SPHERE_SHAPE_PROXYTYPE,
00042 CAPSULE_SHAPE_PROXYTYPE,
00043 CONE_SHAPE_PROXYTYPE,
00044 CONVEX_SHAPE_PROXYTYPE,
00045 CYLINDER_SHAPE_PROXYTYPE,
00046 UNIFORM_SCALING_SHAPE_PROXYTYPE,
00047 MINKOWSKI_SUM_SHAPE_PROXYTYPE,
00048 MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
00049 BOX_2D_SHAPE_PROXYTYPE,
00050 CONVEX_2D_SHAPE_PROXYTYPE,
00051 CUSTOM_CONVEX_SHAPE_TYPE,
00052
00053 CONCAVE_SHAPES_START_HERE,
00054
00055 TRIANGLE_MESH_SHAPE_PROXYTYPE,
00056 SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE,
00058 FAST_CONCAVE_MESH_PROXYTYPE,
00059
00060 TERRAIN_SHAPE_PROXYTYPE,
00062 GIMPACT_SHAPE_PROXYTYPE,
00064 MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE,
00065
00066 EMPTY_SHAPE_PROXYTYPE,
00067 STATIC_PLANE_PROXYTYPE,
00068 CUSTOM_CONCAVE_SHAPE_TYPE,
00069 CONCAVE_SHAPES_END_HERE,
00070
00071 COMPOUND_SHAPE_PROXYTYPE,
00072
00073 SOFTBODY_SHAPE_PROXYTYPE,
00074 HFFLUID_SHAPE_PROXYTYPE,
00075 HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE,
00076 INVALID_SHAPE_PROXYTYPE,
00077
00078 MAX_BROADPHASE_COLLISION_TYPES
00079
00080 };
00081
00082
00085 ATTRIBUTE_ALIGNED16(struct) btBroadphaseProxy
00086 {
00087
00088 BT_DECLARE_ALIGNED_ALLOCATOR();
00089
00091 enum CollisionFilterGroups
00092 {
00093 DefaultFilter = 1,
00094 StaticFilter = 2,
00095 KinematicFilter = 4,
00096 DebrisFilter = 8,
00097 SensorTrigger = 16,
00098 CharacterFilter = 32,
00099 AllFilter = -1
00100 };
00101
00102
00103 void* m_clientObject;
00104 short int m_collisionFilterGroup;
00105 short int m_collisionFilterMask;
00106 void* m_multiSapParentProxy;
00107 int m_uniqueId;
00108
00109 btVector3 m_aabbMin;
00110 btVector3 m_aabbMax;
00111
00112 SIMD_FORCE_INLINE int getUid() const
00113 {
00114 return m_uniqueId;
00115 }
00116
00117
00118 btBroadphaseProxy() :m_clientObject(0),m_multiSapParentProxy(0)
00119 {
00120 }
00121
00122 btBroadphaseProxy(const btVector3& aabbMin,const btVector3& aabbMax,void* userPtr,short int collisionFilterGroup, short int collisionFilterMask,void* multiSapParentProxy=0)
00123 :m_clientObject(userPtr),
00124 m_collisionFilterGroup(collisionFilterGroup),
00125 m_collisionFilterMask(collisionFilterMask),
00126 m_aabbMin(aabbMin),
00127 m_aabbMax(aabbMax)
00128 {
00129 m_multiSapParentProxy = multiSapParentProxy;
00130 }
00131
00132
00133
00134 static SIMD_FORCE_INLINE bool isPolyhedral(int proxyType)
00135 {
00136 return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE);
00137 }
00138
00139 static SIMD_FORCE_INLINE bool isConvex(int proxyType)
00140 {
00141 return (proxyType < CONCAVE_SHAPES_START_HERE);
00142 }
00143
00144 static SIMD_FORCE_INLINE bool isConcave(int proxyType)
00145 {
00146 return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
00147 (proxyType < CONCAVE_SHAPES_END_HERE));
00148 }
00149 static SIMD_FORCE_INLINE bool isCompound(int proxyType)
00150 {
00151 return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
00152 }
00153
00154 static SIMD_FORCE_INLINE bool isSoftBody(int proxyType)
00155 {
00156 return (proxyType == SOFTBODY_SHAPE_PROXYTYPE);
00157 }
00158
00159 static SIMD_FORCE_INLINE bool isInfinite(int proxyType)
00160 {
00161 return (proxyType == STATIC_PLANE_PROXYTYPE);
00162 }
00163
00164 static SIMD_FORCE_INLINE bool isConvex2d(int proxyType)
00165 {
00166 return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE);
00167 }
00168
00169
00170 }
00171 ;
00172
00173 class btCollisionAlgorithm;
00174
00175 struct btBroadphaseProxy;
00176
00177
00178
00181 ATTRIBUTE_ALIGNED16(struct) btBroadphasePair
00182 {
00183 btBroadphasePair ()
00184 :
00185 m_pProxy0(0),
00186 m_pProxy1(0),
00187 m_algorithm(0),
00188 m_internalInfo1(0)
00189 {
00190 }
00191
00192 BT_DECLARE_ALIGNED_ALLOCATOR();
00193
00194 btBroadphasePair(const btBroadphasePair& other)
00195 : m_pProxy0(other.m_pProxy0),
00196 m_pProxy1(other.m_pProxy1),
00197 m_algorithm(other.m_algorithm),
00198 m_internalInfo1(other.m_internalInfo1)
00199 {
00200 }
00201 btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
00202 {
00203
00204
00205 if (proxy0.m_uniqueId < proxy1.m_uniqueId)
00206 {
00207 m_pProxy0 = &proxy0;
00208 m_pProxy1 = &proxy1;
00209 }
00210 else
00211 {
00212 m_pProxy0 = &proxy1;
00213 m_pProxy1 = &proxy0;
00214 }
00215
00216 m_algorithm = 0;
00217 m_internalInfo1 = 0;
00218
00219 }
00220
00221 btBroadphaseProxy* m_pProxy0;
00222 btBroadphaseProxy* m_pProxy1;
00223
00224 mutable btCollisionAlgorithm* m_algorithm;
00225 union { void* m_internalInfo1; int m_internalTmpValue;};
00226
00227 };
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 class btBroadphasePairSortPredicate
00241 {
00242 public:
00243
00244 bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
00245 {
00246 const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
00247 const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
00248 const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
00249 const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
00250
00251 return uidA0 > uidB0 ||
00252 (a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
00253 (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
00254 }
00255 };
00256
00257
00258 SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b)
00259 {
00260 return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
00261 }
00262
00263
00264 #endif //BROADPHASE_PROXY_H
00265