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
00284 float planeTolerance;
00285
00293 PxConvexMeshCookingType::Enum convexMeshCookingType;
00294
00302 bool suppressTriangleMeshRemapTable;
00303
00310 bool buildTriangleAdjacencies;
00311
00317 bool buildGPUData;
00318
00326 PxTolerancesScale scale;
00327
00333 PxMeshPreprocessingFlags meshPreprocessParams;
00334
00344 PX_DEPRECATED PxMeshCookingHint::Enum meshCookingHint;
00345
00359 PX_DEPRECATED PxF32 meshSizePerformanceTradeOff;
00360
00376 PxReal meshWeldTolerance;
00377
00388 PxMidphaseDesc midphaseDesc;
00389
00397 PxU32 gaussMapLimit;
00398
00399 PxCookingParams(const PxTolerancesScale& sc):
00400 skinWidth (0.025f*sc.length),
00401 areaTestEpsilon (0.06f*sc.length*sc.length),
00402 planeTolerance (0.0007f),
00403 convexMeshCookingType (PxConvexMeshCookingType::eQUICKHULL),
00404 suppressTriangleMeshRemapTable (false),
00405 buildTriangleAdjacencies (false),
00406 buildGPUData (false),
00407 scale (sc),
00408 meshPreprocessParams (0),
00409 meshCookingHint (PxMeshCookingHint::eSIM_PERFORMANCE),
00410 meshSizePerformanceTradeOff (0.55f),
00411 meshWeldTolerance (0.f)
00412 {
00413 #if PX_INTEL_FAMILY
00414 targetPlatform = PxPlatform::ePC;
00415 #elif PX_ARM_FAMILY
00416 targetPlatform = PxPlatform::eARM;
00417 #else
00418 #error Unknown platform
00419 #endif
00420 gaussMapLimit = PxGetGaussMapVertexLimitForPlatform(targetPlatform);
00421 }
00422 };
00423
00424 class PxCooking
00425 {
00426 public:
00435 virtual void release() = 0;
00436
00444 virtual void setParams(const PxCookingParams& params) = 0;
00445
00453 virtual const PxCookingParams& getParams() const = 0;
00454
00460 virtual bool platformMismatch() const = 0;
00461
00482 virtual bool cookTriangleMesh(const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
00483
00495 virtual PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
00496
00510 virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) const = 0;
00511
00535 virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
00536
00551 virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
00552
00566 virtual bool validateConvexMesh(const PxConvexMeshDesc& desc) const = 0;
00567
00568
00590 virtual bool computeHullPolygons(const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback, PxU32& nbVerts, PxVec3*& vertices,
00591 PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons) const = 0;
00592
00607 virtual bool cookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream) const = 0;
00608
00618 virtual PxHeightField* createHeightField(const PxHeightFieldDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
00619
00620
00621 protected:
00622 virtual ~PxCooking(){}
00623 };
00624
00625 #if !PX_DOXYGEN
00626 }
00627 #endif
00628
00646 PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCooking* PX_CALL_CONV PxCreateCooking(physx::PxU32 version,
00647 physx::PxFoundation& foundation,
00648 const physx::PxCookingParams& params);
00649
00651 #endif