#ifndef PX_COOKING_H
#define PX_COOKING_H
#include "common/PxPhysXCommonConfig.h"
#include "common/PxTolerancesScale.h"
#include "cooking/Pxc.h"
#include "cooking/PxConvexMeshDesc.h"
#include "cooking/PxTriangleMeshDesc.h"
#include "cooking/PxMidphaseDesc.h"
#include "cooking/PxBVHStructureDesc.h"
#include "geometry/PxTriangleMesh.h"
#include "geometry/PxBVHStructure.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxPhysicsInsertionCallback;
class PxFoundation;
struct PxConvexMeshCookingResult
{
enum Enum
{
eSUCCESS,
eZERO_AREA_TEST_FAILED,
ePOLYGONS_LIMIT_REACHED,
eFAILURE
};
};
struct PxConvexMeshCookingType
{
enum Enum
{
eQUICKHULL
};
};
struct PxTriangleMeshCookingResult
{
enum Enum
{
eSUCCESS = 0,
eLARGE_TRIANGLE,
eFAILURE
};
};
struct PxMeshPreprocessingFlag
{
enum Enum
{
eWELD_VERTICES = 1 << 0,
eDISABLE_CLEAN_MESH = 1 << 1,
eDISABLE_ACTIVE_EDGES_PRECOMPUTE = 1 << 2,
eFORCE_32BIT_INDICES = 1 << 3
};
};
typedef PxFlags<PxMeshPreprocessingFlag::Enum,PxU32> PxMeshPreprocessingFlags;
struct PxCookingParams
{
float areaTestEpsilon;
float planeTolerance;
PxConvexMeshCookingType::Enum convexMeshCookingType;
bool suppressTriangleMeshRemapTable;
bool buildTriangleAdjacencies;
bool buildGPUData;
PxTolerancesScale scale;
PxMeshPreprocessingFlags meshPreprocessParams;
PxReal meshWeldTolerance;
PxMidphaseDesc midphaseDesc;
PxU32 gaussMapLimit;
PxCookingParams(const PxTolerancesScale& sc):
areaTestEpsilon (0.06f*sc.length*sc.length),
planeTolerance (0.0007f),
convexMeshCookingType (PxConvexMeshCookingType::eQUICKHULL),
suppressTriangleMeshRemapTable (false),
buildTriangleAdjacencies (false),
buildGPUData (false),
scale (sc),
meshPreprocessParams (0),
meshWeldTolerance (0.f),
gaussMapLimit (32)
{
}
};
class PxCooking
{
public:
virtual void release() = 0;
virtual void setParams(const PxCookingParams& params) = 0;
virtual const PxCookingParams& getParams() const = 0;
virtual bool platformMismatch() const = 0;
virtual bool cookTriangleMesh(const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
virtual PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) const = 0;
virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
virtual bool validateConvexMesh(const PxConvexMeshDesc& desc) const = 0;
virtual bool computeHullPolygons(const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback, PxU32& nbVerts, PxVec3*& vertices,
PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons) const = 0;
virtual bool cookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream) const = 0;
virtual PxHeightField* createHeightField(const PxHeightFieldDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
virtual bool cookBVHStructure(const PxBVHStructureDesc& desc, PxOutputStream& stream) const = 0;
virtual PxBVHStructure* createBVHStructure(const PxBVHStructureDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
protected:
virtual ~PxCooking(){}
};
#if !PX_DOXYGEN
} #endif
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCooking* PX_CALL_CONV PxCreateCooking(physx::PxU32 version,
physx::PxFoundation& foundation,
const physx::PxCookingParams& params);
#endif