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_COOKING_H
00032 #define PX_COOKING_H
00033
00036 #include "common/PxPhysXCommonConfig.h"
00037 #include "common/PxTolerancesScale.h"
00038 #include "cooking/Pxc.h"
00039
00040 #include "cooking/PxConvexMeshDesc.h"
00041 #include "cooking/PxTriangleMeshDesc.h"
00042 #include "cooking/PxMidphaseDesc.h"
00043 #include "cooking/PxBVHStructureDesc.h"
00044 #include "geometry/PxTriangleMesh.h"
00045 #include "geometry/PxBVHStructure.h"
00046
00047 #if !PX_DOXYGEN
00048 namespace physx
00049 {
00050 #endif
00051
00052 class PxPhysicsInsertionCallback;
00053 class PxFoundation;
00054
00058 struct PxConvexMeshCookingResult
00059 {
00060 enum Enum
00061 {
00065 eSUCCESS,
00066
00072 eZERO_AREA_TEST_FAILED,
00073
00081 ePOLYGONS_LIMIT_REACHED,
00082
00086 eFAILURE
00087 };
00088 };
00089
00091 struct PxConvexMeshCookingType
00092 {
00093 enum Enum
00094 {
00107 eINFLATION_INCREMENTAL_HULL PX_DEPRECATED = 0,
00108
00114 eQUICKHULL
00115 };
00116 };
00117
00121 struct PxTriangleMeshCookingResult
00122 {
00123 enum Enum
00124 {
00128 eSUCCESS = 0,
00129
00133 eLARGE_TRIANGLE,
00134
00138 eFAILURE
00139 };
00140 };
00141
00148 struct PxMeshPreprocessingFlag
00149 {
00150 enum Enum
00151 {
00155 eWELD_VERTICES = 1 << 0,
00156
00165 eDISABLE_CLEAN_MESH = 1 << 1,
00166
00170 eDISABLE_ACTIVE_EDGES_PRECOMPUTE = 1 << 2,
00171
00177 eFORCE_32BIT_INDICES = 1 << 3
00178 };
00179 };
00180
00181 typedef PxFlags<PxMeshPreprocessingFlag::Enum,PxU32> PxMeshPreprocessingFlags;
00182
00189 struct PxCookingParams
00190 {
00213 PX_DEPRECATED float skinWidth;
00214
00227 float areaTestEpsilon;
00228
00249 float planeTolerance;
00250
00258 PxConvexMeshCookingType::Enum convexMeshCookingType;
00259
00267 bool suppressTriangleMeshRemapTable;
00268
00275 bool buildTriangleAdjacencies;
00276
00282 bool buildGPUData;
00283
00291 PxTolerancesScale scale;
00292
00298 PxMeshPreprocessingFlags meshPreprocessParams;
00299
00315 PxReal meshWeldTolerance;
00316
00324 PxMidphaseDesc midphaseDesc;
00325
00333 PxU32 gaussMapLimit;
00334
00335 PxCookingParams(const PxTolerancesScale& sc):
00336 skinWidth (0.025f*sc.length),
00337 areaTestEpsilon (0.06f*sc.length*sc.length),
00338 planeTolerance (0.0007f),
00339 convexMeshCookingType (PxConvexMeshCookingType::eQUICKHULL),
00340 suppressTriangleMeshRemapTable (false),
00341 buildTriangleAdjacencies (false),
00342 buildGPUData (false),
00343 scale (sc),
00344 meshPreprocessParams (0),
00345 meshWeldTolerance (0.f),
00346 gaussMapLimit (32)
00347 {
00348 }
00349 };
00350
00351 class PxCooking
00352 {
00353 public:
00362 virtual void release() = 0;
00363
00371 virtual void setParams(const PxCookingParams& params) = 0;
00372
00380 virtual const PxCookingParams& getParams() const = 0;
00381
00387 virtual bool platformMismatch() const = 0;
00388
00409 virtual bool cookTriangleMesh(const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
00410
00411
00424 virtual PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
00425
00439 virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) const = 0;
00440
00441
00465 virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
00466
00482 virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
00483
00497 virtual bool validateConvexMesh(const PxConvexMeshDesc& desc) const = 0;
00498
00499
00521 virtual bool computeHullPolygons(const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback, PxU32& nbVerts, PxVec3*& vertices,
00522 PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons) const = 0;
00523
00538 virtual bool cookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream) const = 0;
00539
00549 virtual PxHeightField* createHeightField(const PxHeightFieldDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
00550
00563 virtual bool cookBVHStructure(const PxBVHStructureDesc& desc, PxOutputStream& stream) const = 0;
00564
00579 virtual PxBVHStructure* createBVHStructure(const PxBVHStructureDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
00580 protected:
00581 virtual ~PxCooking(){}
00582 };
00583
00584 #if !PX_DOXYGEN
00585 }
00586 #endif
00587
00605 PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCooking* PX_CALL_CONV PxCreateCooking(physx::PxU32 version,
00606 physx::PxFoundation& foundation,
00607 const physx::PxCookingParams& params);
00608
00610 #endif