00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_BROADPHASE_PROXY_H
00017 #define BT_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 isNonMoving(int proxyType)
00145 {
00146 return (isConcave(proxyType) && !(proxyType==GIMPACT_SHAPE_PROXYTYPE));
00147 }
00148
00149 static SIMD_FORCE_INLINE bool isConcave(int proxyType)
00150 {
00151 return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
00152 (proxyType < CONCAVE_SHAPES_END_HERE));
00153 }
00154 static SIMD_FORCE_INLINE bool isCompound(int proxyType)
00155 {
00156 return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
00157 }
00158
00159 static SIMD_FORCE_INLINE bool isSoftBody(int proxyType)
00160 {
00161 return (proxyType == SOFTBODY_SHAPE_PROXYTYPE);
00162 }
00163
00164 static SIMD_FORCE_INLINE bool isInfinite(int proxyType)
00165 {
00166 return (proxyType == STATIC_PLANE_PROXYTYPE);
00167 }
00168
00169 static SIMD_FORCE_INLINE bool isConvex2d(int proxyType)
00170 {
00171 return (proxyType == BOX_2D_SHAPE_PROXYTYPE) || (proxyType == CONVEX_2D_SHAPE_PROXYTYPE);
00172 }
00173
00174
00175 }
00176 ;
00177
00178 class btCollisionAlgorithm;
00179
00180 struct btBroadphaseProxy;
00181
00182
00183
00186 ATTRIBUTE_ALIGNED16(struct) btBroadphasePair
00187 {
00188 btBroadphasePair ()
00189 :
00190 m_pProxy0(0),
00191 m_pProxy1(0),
00192 m_algorithm(0),
00193 m_internalInfo1(0)
00194 {
00195 }
00196
00197 BT_DECLARE_ALIGNED_ALLOCATOR();
00198
00199 btBroadphasePair(const btBroadphasePair& other)
00200 : m_pProxy0(other.m_pProxy0),
00201 m_pProxy1(other.m_pProxy1),
00202 m_algorithm(other.m_algorithm),
00203 m_internalInfo1(other.m_internalInfo1)
00204 {
00205 }
00206 btBroadphasePair(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
00207 {
00208
00209
00210 if (proxy0.m_uniqueId < proxy1.m_uniqueId)
00211 {
00212 m_pProxy0 = &proxy0;
00213 m_pProxy1 = &proxy1;
00214 }
00215 else
00216 {
00217 m_pProxy0 = &proxy1;
00218 m_pProxy1 = &proxy0;
00219 }
00220
00221 m_algorithm = 0;
00222 m_internalInfo1 = 0;
00223
00224 }
00225
00226 btBroadphaseProxy* m_pProxy0;
00227 btBroadphaseProxy* m_pProxy1;
00228
00229 mutable btCollisionAlgorithm* m_algorithm;
00230 union { void* m_internalInfo1; int m_internalTmpValue;};
00231
00232 };
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 class btBroadphasePairSortPredicate
00246 {
00247 public:
00248
00249 bool operator() ( const btBroadphasePair& a, const btBroadphasePair& b )
00250 {
00251 const int uidA0 = a.m_pProxy0 ? a.m_pProxy0->m_uniqueId : -1;
00252 const int uidB0 = b.m_pProxy0 ? b.m_pProxy0->m_uniqueId : -1;
00253 const int uidA1 = a.m_pProxy1 ? a.m_pProxy1->m_uniqueId : -1;
00254 const int uidB1 = b.m_pProxy1 ? b.m_pProxy1->m_uniqueId : -1;
00255
00256 return uidA0 > uidB0 ||
00257 (a.m_pProxy0 == b.m_pProxy0 && uidA1 > uidB1) ||
00258 (a.m_pProxy0 == b.m_pProxy0 && a.m_pProxy1 == b.m_pProxy1 && a.m_algorithm > b.m_algorithm);
00259 }
00260 };
00261
00262
00263 SIMD_FORCE_INLINE bool operator==(const btBroadphasePair& a, const btBroadphasePair& b)
00264 {
00265 return (a.m_pProxy0 == b.m_pProxy0) && (a.m_pProxy1 == b.m_pProxy1);
00266 }
00267
00268
00269 #endif //BT_BROADPHASE_PROXY_H
00270