00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef PX_COLLISION_NXCONVEXMESHDESC
00032 #define PX_COLLISION_NXCONVEXMESHDESC
00033
00037 #include "foundation/PxVec3.h"
00038 #include "foundation/PxFlags.h"
00039 #include "common/PxCoreUtilityTypes.h"
00040 #include "geometry/PxConvexMesh.h"
00041
00042 #if !PX_DOXYGEN
00043 namespace physx
00044 {
00045 #endif
00046
00050 struct PxConvexFlag
00051 {
00052 enum Enum
00053 {
00059 e16_BIT_INDICES = (1<<0),
00060
00068 eCOMPUTE_CONVEX = (1<<1),
00069
00081 eCHECK_ZERO_AREA_TRIANGLES = (1<<2),
00082
00092 PX_DEPRECATED eINFLATE_CONVEX = (1<<3),
00093
00101 eQUANTIZE_INPUT = (1 << 4),
00102
00110 eDISABLE_MESH_VALIDATION = (1 << 5),
00111
00129 ePLANE_SHIFTING = (1 << 6),
00130
00135 eFAST_INERTIA_COMPUTATION = (1 << 7),
00136
00142 eGPU_COMPATIBLE = (1 << 8),
00143
00150 eSHIFT_VERTICES = (1 << 9)
00151 };
00152 };
00153
00159 typedef PxFlags<PxConvexFlag::Enum,PxU16> PxConvexFlags;
00160 PX_FLAGS_OPERATORS(PxConvexFlag::Enum,PxU16)
00161
00162
00169 class PxConvexMeshDesc
00170 {
00171 public:
00172
00178 PxBoundedData points;
00179
00188 PxBoundedData polygons;
00189
00200 PxBoundedData indices;
00201
00207 PxConvexFlags flags;
00208
00222 PxU16 vertexLimit;
00223
00233 PxU16 quantizedCount;
00234
00238 PX_INLINE PxConvexMeshDesc();
00242 PX_INLINE void setToDefault();
00248 PX_INLINE bool isValid() const;
00249 };
00250
00251 PX_INLINE PxConvexMeshDesc::PxConvexMeshDesc()
00252 : vertexLimit(255), quantizedCount(255)
00253 {
00254 }
00255
00256 PX_INLINE void PxConvexMeshDesc::setToDefault()
00257 {
00258 *this = PxConvexMeshDesc();
00259 }
00260
00261 PX_INLINE bool PxConvexMeshDesc::isValid() const
00262 {
00263
00264 if(points.count < 3 ||
00265 (points.count > 0xffff && flags & PxConvexFlag::e16_BIT_INDICES))
00266 return false;
00267 if(!points.data)
00268 return false;
00269 if(points.stride < sizeof(PxVec3))
00270 return false;
00271 if (quantizedCount < 4)
00272 return false;
00273
00274
00275 if(polygons.data)
00276 {
00277 if(polygons.count < 4)
00278 return false;
00279
00280 if(!indices.data)
00281 return false;
00282
00283 PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16) : sizeof(PxU32);
00284 if(indices.stride < limit)
00285 return false;
00286
00287 limit = sizeof(PxHullPolygon);
00288 if(polygons.stride < limit)
00289 return false;
00290 }
00291 else
00292 {
00293
00294 if(!(flags & PxConvexFlag::eCOMPUTE_CONVEX))
00295 return false;
00296
00297 }
00298
00299 if((flags & PxConvexFlag::ePLANE_SHIFTING) && vertexLimit < 4)
00300 {
00301 return false;
00302 }
00303
00304 if (!(flags & PxConvexFlag::ePLANE_SHIFTING) && vertexLimit < 8)
00305 {
00306 return false;
00307 }
00308
00309 if(vertexLimit > 256)
00310 {
00311 return false;
00312 }
00313 return true;
00314 }
00315
00316 #if !PX_DOXYGEN
00317 }
00318 #endif
00319
00321 #endif