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 "geometry/PxTriangleMesh.h"
00044
00045 #if !PX_DOXYGEN
00046 namespace physx
00047 {
00048 #endif
00049
00050 class PxBinaryConverter;
00051 class PxPhysicsInsertionCallback;
00052 class PxFoundation;
00053
00054 struct PX_DEPRECATED PxPlatform
00055 {
00056 enum Enum
00057 {
00058 ePC,
00059 eARM
00060 };
00061 };
00062
00063 PX_DEPRECATED PX_FORCE_INLINE PxU32 PxGetGaussMapVertexLimitForPlatform(PxPlatform::Enum targetPlatform)
00064 {
00065 PX_ASSERT_WITH_MESSAGE( (targetPlatform >= PxPlatform::ePC) &&
00066 (targetPlatform <= PxPlatform::eARM),
00067 "Unexpected platform in PxGetGaussMapVertexLimitForPlatform");
00068
00069 PxU32 limit = 0;
00070 switch(targetPlatform)
00071 {
00072 case PxPlatform::ePC:
00073 limit = 32; break;
00074 case PxPlatform::eARM:
00075 limit = 32; break;
00076 }
00077 return limit;
00078 }
00079
00083 struct PxConvexMeshCookingResult
00084 {
00085 enum Enum
00086 {
00090 eSUCCESS,
00091
00097 eZERO_AREA_TEST_FAILED,
00098
00106 ePOLYGONS_LIMIT_REACHED,
00107
00111 eFAILURE
00112 };
00113 };
00114
00116 struct PxConvexMeshCookingType
00117 {
00118 enum Enum
00119 {
00132 eINFLATION_INCREMENTAL_HULL PX_DEPRECATED = 0,
00133
00139 eQUICKHULL
00140 };
00141 };
00142
00146 struct PxTriangleMeshCookingResult
00147 {
00148 enum Enum
00149 {
00153 eSUCCESS = 0,
00154
00158 eLARGE_TRIANGLE,
00159
00163 eFAILURE
00164 };
00165 };
00166
00173 struct PxMeshPreprocessingFlag
00174 {
00175 enum Enum
00176 {
00180 eWELD_VERTICES = 1 << 0,
00181
00190 eDISABLE_CLEAN_MESH = 1 << 1,
00191
00195 eDISABLE_ACTIVE_EDGES_PRECOMPUTE = 1 << 2,
00196
00202 eFORCE_32BIT_INDICES = 1 << 3
00203 };
00204 };
00205
00206 typedef PxFlags<PxMeshPreprocessingFlag::Enum,PxU32> PxMeshPreprocessingFlags;
00207
00214 struct PxCookingParams
00215 {
00225 PxPlatform::Enum targetPlatform;
00248 PX_DEPRECATED float skinWidth;
00249
00262 float areaTestEpsilon;
00263
00271 PxConvexMeshCookingType::Enum convexMeshCookingType;
00272
00280 bool suppressTriangleMeshRemapTable;
00281
00288 bool buildTriangleAdjacencies;
00289
00295 bool buildGPUData;
00296
00304 PxTolerancesScale scale;
00305
00311 PxMeshPreprocessingFlags meshPreprocessParams;
00312
00322 PX_DEPRECATED PxMeshCookingHint::Enum meshCookingHint;
00323
00337 PX_DEPRECATED PxF32 meshSizePerformanceTradeOff;
00338
00354 PxReal meshWeldTolerance;
00355
00366 PxMidphaseDesc midphaseDesc;
00367
00375 PxU32 gaussMapLimit;
00376
00377 PxCookingParams(const PxTolerancesScale& sc):
00378 skinWidth (0.025f*sc.length),
00379 areaTestEpsilon (0.06f*sc.length*sc.length),
00380 convexMeshCookingType (PxConvexMeshCookingType::eQUICKHULL),
00381 suppressTriangleMeshRemapTable (false),
00382 buildTriangleAdjacencies (false),
00383 buildGPUData (false),
00384 scale (sc),
00385 meshPreprocessParams (0),
00386 meshCookingHint (PxMeshCookingHint::eSIM_PERFORMANCE),
00387 meshSizePerformanceTradeOff (0.55f),
00388 meshWeldTolerance (0.f)
00389 {
00390 #if PX_INTEL_FAMILY
00391 targetPlatform = PxPlatform::ePC;
00392 #elif PX_ARM_FAMILY
00393 targetPlatform = PxPlatform::eARM;
00394 #else
00395 #error Unknown platform
00396 #endif
00397 gaussMapLimit = PxGetGaussMapVertexLimitForPlatform(targetPlatform);
00398 }
00399 };
00400
00401 class PxCooking
00402 {
00403 public:
00412 virtual void release() = 0;
00413
00421 virtual void setParams(const PxCookingParams& params) = 0;
00422
00430 virtual const PxCookingParams& getParams() = 0;
00431
00437 virtual bool platformMismatch() = 0;
00438
00459 virtual bool cookTriangleMesh(const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition = NULL) = 0;
00460
00472 virtual PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback) = 0;
00473
00487 virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) = 0;
00488
00512 virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition = NULL) = 0;
00513
00528 virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback) = 0;
00529
00543 virtual bool validateConvexMesh(const PxConvexMeshDesc& desc) = 0;
00544
00545
00567 virtual bool computeHullPolygons(const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback, PxU32& nbVerts, PxVec3*& vertices,
00568 PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons) = 0;
00569
00584 virtual bool cookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream) = 0;
00585
00595 virtual PxHeightField* createHeightField(const PxHeightFieldDesc& desc, PxPhysicsInsertionCallback& insertionCallback) = 0;
00596
00597
00598 protected:
00599 virtual ~PxCooking(){}
00600 };
00601
00602 #if !PX_DOXYGEN
00603 }
00604 #endif
00605
00623 PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCooking* PX_CALL_CONV PxCreateCooking(physx::PxU32 version,
00624 physx::PxFoundation& foundation,
00625 const physx::PxCookingParams& params);
00626
00628 #endif