Program Listing for include/cooking/PxCooking.h
↰ Return to documentation for include/cooking/PxCooking.h
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#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/PxTetrahedronMeshDesc.h"
#include "cooking/PxMidphaseDesc.h"
#include "cooking/PxBVHDesc.h"
#include "geometry/PxTriangleMesh.h"
#include "geometry/PxTetrahedronMesh.h"
#include "geometry/PxBVH.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxInsertionCallback;
class PxFoundation;
class PxAllocatorCallback;
class PxHeightFieldDesc;
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,
eENABLE_VERT_MAPPING = 1 << 4,
eENABLE_INERTIA = 1 << 5
};
};
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;
PxReal maxWeightRatioInTet;
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),
maxWeightRatioInTet (FLT_MAX)
{
}
};
class PX_DEPRECATED 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, PxInsertionCallback& insertionCallback, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
PX_FORCE_INLINE PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc) const
{
return createTriangleMesh(desc, const_cast<PxCooking&>(*this).getStandaloneInsertionCallback());
}
virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) const = 0;
virtual bool cookSoftBodyMesh(const PxTetrahedronMeshDesc& simulationMeshDesc, const PxTetrahedronMeshDesc& collisionMeshDesc,
const PxSoftBodySimulationDataDesc& softbodyDataDesc, PxOutputStream& stream) const = 0;
virtual PxSoftBodyMesh* createSoftBodyMesh(const PxTetrahedronMeshDesc& simulationMeshDesc, const PxTetrahedronMeshDesc& collisionMeshDesc,
const PxSoftBodySimulationDataDesc& softbodyDataDesc, PxInsertionCallback& insertionCallback) const = 0;
PX_FORCE_INLINE PxSoftBodyMesh* createSoftBodyMesh(const PxTetrahedronMeshDesc& simulationMeshDesc, const PxTetrahedronMeshDesc& collisionMeshDesc,
const PxSoftBodySimulationDataDesc& softbodyDataDesc) const
{
return createSoftBodyMesh(simulationMeshDesc, collisionMeshDesc, softbodyDataDesc, const_cast<PxCooking&>(*this).getStandaloneInsertionCallback());
}
virtual bool cookTetrahedronMesh(const PxTetrahedronMeshDesc& meshDesc, PxOutputStream& stream) const = 0;
virtual PxTetrahedronMesh* createTetrahedronMesh(const PxTetrahedronMeshDesc& meshDesc, PxInsertionCallback& insertionCallback) const = 0;
PX_FORCE_INLINE PxTetrahedronMesh* createTetrahedronMesh(const PxTetrahedronMeshDesc& meshDesc) const
{
return createTetrahedronMesh(meshDesc, const_cast<PxCooking&>(*this).getStandaloneInsertionCallback());
}
virtual PxCollisionMeshMappingData* computeModelsMapping(PxTetrahedronMeshData& simulationMesh, const PxTetrahedronMeshData& collisionMesh,
const PxSoftBodyCollisionData& collisionData, const PxBoundedData* vertexToTet = NULL) const = 0;
virtual PxCollisionTetrahedronMeshData* computeCollisionData(const PxTetrahedronMeshDesc& collisionMeshDesc) const = 0;
virtual PxSimulationTetrahedronMeshData* computeSimulationData(const PxTetrahedronMeshDesc& simulationMeshDesc) const = 0;
virtual PxSoftBodyMesh* assembleSoftBodyMesh(PxTetrahedronMeshData& simulationMesh, PxSoftBodySimulationData& simulationData, PxTetrahedronMeshData& collisionMesh,
PxSoftBodyCollisionData& collisionData, PxCollisionMeshMappingData& mappingData, PxInsertionCallback& insertionCallback) const = 0;
virtual PxSoftBodyMesh* assembleSoftBodyMesh(PxSimulationTetrahedronMeshData& simulationMesh, PxCollisionTetrahedronMeshData& collisionMesh,
PxCollisionMeshMappingData& mappingData, PxInsertionCallback& insertionCallback) const = 0;
virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxInsertionCallback& insertionCallback, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
PX_FORCE_INLINE PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc) const
{
return createConvexMesh(desc, const_cast<PxCooking&>(*this).getStandaloneInsertionCallback());
}
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, PxInsertionCallback& insertionCallback) const = 0;
PX_FORCE_INLINE PxHeightField* createHeightField(const PxHeightFieldDesc& desc) const
{
return createHeightField(desc, const_cast<PxCooking&>(*this).getStandaloneInsertionCallback());
}
virtual bool cookBVH(const PxBVHDesc& desc, PxOutputStream& stream) const = 0;
PX_DEPRECATED PX_FORCE_INLINE bool cookBVHStructure(const PxBVHStructureDesc& desc, PxOutputStream& stream) const
{
return cookBVH(desc, stream);
}
virtual PxBVH* createBVH(const PxBVHDesc& desc, PxInsertionCallback& insertionCallback) const = 0;
PX_FORCE_INLINE PxBVH* createBVH(const PxBVHDesc& desc) const
{
return createBVH(desc, const_cast<PxCooking&>(*this).getStandaloneInsertionCallback());
}
PX_DEPRECATED PX_FORCE_INLINE PxBVHStructure* createBVHStructure(const PxBVHStructureDesc& desc, PxInsertionCallback& insertionCallback) const
{
return createBVH(desc, insertionCallback);
}
virtual PxInsertionCallback& getStandaloneInsertionCallback() = 0;
protected:
virtual ~PxCooking(){}
};
#if !PX_DOXYGEN
} // namespace physx
#endif
PX_C_EXPORT PX_PHYSX_COOKING_API PX_DEPRECATED physx::PxCooking* PX_CALL_CONV PxCreateCooking(physx::PxU32 version,
physx::PxFoundation& foundation,
const physx::PxCookingParams& params);
// Immediate cooking
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxInsertionCallback* PxGetStandaloneInsertionCallback();
// BVH
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookBVH(const physx::PxBVHDesc& desc, physx::PxOutputStream& stream);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxBVH* PxCreateBVH(const physx::PxBVHDesc& desc, physx::PxInsertionCallback& insertionCallback);
PX_FORCE_INLINE physx::PxBVH* PxCreateBVH(const physx::PxBVHDesc& desc)
{
return PxCreateBVH(desc, *PxGetStandaloneInsertionCallback());
}
// Heightfield
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookHeightField(const physx::PxHeightFieldDesc& desc, physx::PxOutputStream& stream);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxHeightField* PxCreateHeightField(const physx::PxHeightFieldDesc& desc, physx::PxInsertionCallback& insertionCallback);
PX_FORCE_INLINE physx::PxHeightField* PxCreateHeightField(const physx::PxHeightFieldDesc& desc)
{
return PxCreateHeightField(desc, *PxGetStandaloneInsertionCallback());
}
// Convex meshes
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc, physx::PxOutputStream& stream, physx::PxConvexMeshCookingResult::Enum* condition=NULL);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxConvexMesh* PxCreateConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc, physx::PxInsertionCallback& insertionCallback, physx::PxConvexMeshCookingResult::Enum* condition=NULL);
PX_FORCE_INLINE physx::PxConvexMesh* PxCreateConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc)
{
return PxCreateConvexMesh(params, desc, *PxGetStandaloneInsertionCallback());
}
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxValidateConvexMesh(const physx::PxCookingParams& params, const physx::PxConvexMeshDesc& desc);
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxComputeHullPolygons(const physx::PxCookingParams& params, const physx::PxSimpleTriangleMesh& mesh, physx::PxAllocatorCallback& inCallback, physx::PxU32& nbVerts, physx::PxVec3*& vertices,
physx::PxU32& nbIndices, physx::PxU32*& indices, physx::PxU32& nbPolygons, physx::PxHullPolygon*& hullPolygons);
// Triangle meshes
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxValidateTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxTriangleMesh* PxCreateTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc, physx::PxInsertionCallback& insertionCallback, physx::PxTriangleMeshCookingResult::Enum* condition=NULL);
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc, physx::PxOutputStream& stream, physx::PxTriangleMeshCookingResult::Enum* condition=NULL);
PX_FORCE_INLINE physx::PxTriangleMesh* PxCreateTriangleMesh(const physx::PxCookingParams& params, const physx::PxTriangleMeshDesc& desc)
{
return PxCreateTriangleMesh(params, desc, *PxGetStandaloneInsertionCallback());
}
// Tetrahedron & soft body meshes
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookTetrahedronMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& meshDesc, physx::PxOutputStream& stream);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxTetrahedronMesh* PxCreateTetrahedronMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& meshDesc, physx::PxInsertionCallback& insertionCallback);
PX_FORCE_INLINE physx::PxTetrahedronMesh* PxCreateTetrahedronMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& meshDesc)
{
return PxCreateTetrahedronMesh(params, meshDesc, *PxGetStandaloneInsertionCallback());
}
PX_C_EXPORT PX_PHYSX_COOKING_API bool PxCookSoftBodyMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
const physx::PxSoftBodySimulationDataDesc& softbodyDataDesc, physx::PxOutputStream& stream);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxSoftBodyMesh* PxCreateSoftBodyMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
const physx::PxSoftBodySimulationDataDesc& softbodyDataDesc, physx::PxInsertionCallback& insertionCallback);
PX_FORCE_INLINE physx::PxSoftBodyMesh* PxCreateSoftBodyMesh(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& simulationMeshDesc, const physx::PxTetrahedronMeshDesc& collisionMeshDesc,
const physx::PxSoftBodySimulationDataDesc& softbodyDataDesc)
{
return PxCreateSoftBodyMesh(params, simulationMeshDesc, collisionMeshDesc, softbodyDataDesc, *PxGetStandaloneInsertionCallback());
}
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCollisionMeshMappingData* PxComputeModelsMapping(const physx::PxCookingParams& params, physx::PxTetrahedronMeshData& simulationMesh, const physx::PxTetrahedronMeshData& collisionMesh,
const physx::PxSoftBodyCollisionData& collisionData, const physx::PxBoundedData* vertexToTet = NULL);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCollisionTetrahedronMeshData* PxComputeCollisionData(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& collisionMeshDesc);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxSimulationTetrahedronMeshData* PxComputeSimulationData(const physx::PxCookingParams& params, const physx::PxTetrahedronMeshDesc& simulationMeshDesc);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxSoftBodyMesh* PxAssembleSoftBodyMesh(physx::PxTetrahedronMeshData& simulationMesh, physx::PxSoftBodySimulationData& simulationData, physx::PxTetrahedronMeshData& collisionMesh,
physx::PxSoftBodyCollisionData& collisionData, physx::PxCollisionMeshMappingData& mappingData, physx::PxInsertionCallback& insertionCallback);
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxSoftBodyMesh* PxAssembleSoftBodyMesh_Sim(physx::PxSimulationTetrahedronMeshData& simulationMesh, physx::PxCollisionTetrahedronMeshData& collisionMesh,
physx::PxCollisionMeshMappingData& mappingData, physx::PxInsertionCallback& insertionCallback);
#endif