RavEngine
Loading...
Searching...
No Matches
Cooking.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef COOKING_H
30#define COOKING_H
31
32#include "foundation/PxMemory.h"
33#include "cooking/PxCooking.h"
34
35#include "foundation/PxUserAllocated.h"
36
37namespace physx
38{
39class TriangleMeshBuilder;
40class TetrahedronMeshBuilder;
41class ConvexMeshBuilder;
42class ConvexHullLib;
43class PxInsertionCallback;
44struct PxTriangleMeshInternalData;
45struct PxBVHInternalData;
46
47class Cooking : public PxCooking, public PxUserAllocated
48{
49public:
50 Cooking(const PxCookingParams& params): mParams(params) {}
51
52 virtual void release();
53 virtual void setParams(const PxCookingParams& params);
54 virtual const PxCookingParams& getParams() const;
55 virtual bool platformMismatch() const;
56 virtual bool cookTriangleMesh(const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition = NULL) const;
57 virtual PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc, PxInsertionCallback& insertionCallback, PxTriangleMeshCookingResult::Enum* condition = NULL) const;
58 virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) const;
59
60 virtual bool cookSoftBodyMesh(const PxTetrahedronMeshDesc& simulationMeshDesc, const PxTetrahedronMeshDesc& collisionMeshDesc,
61 const PxSoftBodySimulationDataDesc& softbodyDataDesc, PxOutputStream& stream) const;
62 virtual PxSoftBodyMesh* createSoftBodyMesh(const PxTetrahedronMeshDesc& simulationMeshDesc, const PxTetrahedronMeshDesc& collisionMeshDesc,
63 const PxSoftBodySimulationDataDesc& softbodyDataDesc, PxInsertionCallback& insertionCallback) const;
64
65 virtual bool cookTetrahedronMesh(const PxTetrahedronMeshDesc& meshDesc, PxOutputStream& stream) const;
66 virtual PxTetrahedronMesh* createTetrahedronMesh(const PxTetrahedronMeshDesc& meshDesc, PxInsertionCallback& insertionCallback) const;
67
68 virtual PxCollisionMeshMappingData* computeModelsMapping(PxTetrahedronMeshData& simulationMesh, const PxTetrahedronMeshData& collisionMesh, const PxSoftBodyCollisionData& collisionData, const PxBoundedData* vertexToTet) const;
69 virtual PxCollisionTetrahedronMeshData* computeCollisionData(const PxTetrahedronMeshDesc& collisionMeshDesc) const;
70 virtual PxSimulationTetrahedronMeshData* computeSimulationData(const PxTetrahedronMeshDesc& simulationMeshDesc) const;
71 virtual PxSoftBodyMesh* assembleSoftBodyMesh(PxTetrahedronMeshData& simulationMesh, PxSoftBodySimulationData& simulationData, PxTetrahedronMeshData& collisionMesh,
72 PxSoftBodyCollisionData& collisionData, PxCollisionMeshMappingData& mappingData, PxInsertionCallback& insertionCallback) const;
74
75 virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition) const;
76 virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxInsertionCallback& insertionCallback, PxConvexMeshCookingResult::Enum* condition) const;
77 virtual bool validateConvexMesh(const PxConvexMeshDesc& desc) const;
78 virtual bool computeHullPolygons(const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback,PxU32& nbVerts, PxVec3*& vertices,
79 PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons) const;
80 virtual bool cookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream) const;
81 virtual PxHeightField* createHeightField(const PxHeightFieldDesc& desc, PxInsertionCallback& insertionCallback) const;
82 virtual bool cookBVH(const PxBVHDesc& desc, PxOutputStream& stream) const;
83 virtual PxBVH* createBVH(const PxBVHDesc& desc, PxInsertionCallback& insertionCallback) const;
85
87 PxBVH* createBVH(const PxBVHInternalData& data) const;
88
89private:
90 PxCookingParams mParams;
91};
92
93}
94#endif
95
Definition Cooking.h:48
virtual PxTriangleMesh * createTriangleMesh(const PxTriangleMeshDesc &desc, PxInsertionCallback &insertionCallback, PxTriangleMeshCookingResult::Enum *condition=NULL) const
Cooks and creates a triangle mesh without going through a stream.
Definition Cooking.cpp:78
virtual PxBVH * createBVH(const PxBVHDesc &desc, PxInsertionCallback &insertionCallback) const
Cooks and creates a bounding volume hierarchy without going through a stream.
Definition Cooking.cpp:180
virtual PxConvexMesh * createConvexMesh(const PxConvexMeshDesc &desc, PxInsertionCallback &insertionCallback, PxConvexMeshCookingResult::Enum *condition) const
Cooks and creates a convex mesh without going through a stream.
Definition Cooking.cpp:145
virtual bool computeHullPolygons(const PxSimpleTriangleMesh &mesh, PxAllocatorCallback &inCallback, PxU32 &nbVerts, PxVec3 *&vertices, PxU32 &nbIndices, PxU32 *&indices, PxU32 &nbPolygons, PxHullPolygon *&hullPolygons) const
Computed hull polygons from given vertices and triangles. Polygons are needed for PxConvexMeshDesc ra...
Definition Cooking.cpp:155
virtual bool validateTriangleMesh(const PxTriangleMeshDesc &desc) const
Verifies if the triangle mesh is valid. Prints an error message for each inconsistency found.
Definition Cooking.cpp:68
virtual bool cookSoftBodyMesh(const PxTetrahedronMeshDesc &simulationMeshDesc, const PxTetrahedronMeshDesc &collisionMeshDesc, const PxSoftBodySimulationDataDesc &softbodyDataDesc, PxOutputStream &stream) const
Cooks a softbody mesh. The results are written to the stream.
Definition Cooking.cpp:97
virtual PxCollisionTetrahedronMeshData * computeCollisionData(const PxTetrahedronMeshDesc &collisionMeshDesc) const
Computes data to accelerate collision detection of tetrahedral meshes.
Definition Cooking.cpp:108
virtual PxSimulationTetrahedronMeshData * computeSimulationData(const PxTetrahedronMeshDesc &simulationMeshDesc) const
Computes data to accelerate collision detection of tetrahedral meshes.
Definition Cooking.cpp:113
virtual bool validateConvexMesh(const PxConvexMeshDesc &desc) const
Verifies if the convex mesh is valid. Prints an error message for each inconsistency found.
Definition Cooking.cpp:150
virtual bool cookTriangleMesh(const PxTriangleMeshDesc &desc, PxOutputStream &stream, PxTriangleMeshCookingResult::Enum *condition=NULL) const
Cooks a triangle mesh. The results are written to the stream.
Definition Cooking.cpp:73
virtual PxHeightField * createHeightField(const PxHeightFieldDesc &desc, PxInsertionCallback &insertionCallback) const
Cooks and creates a heightfield mesh and inserts it into PxPhysics.
Definition Cooking.cpp:168
virtual void setParams(const PxCookingParams &params)
Sets cooking parameters.
Definition Cooking.cpp:40
virtual PxTetrahedronMesh * createTetrahedronMesh(const PxTetrahedronMeshDesc &meshDesc, PxInsertionCallback &insertionCallback) const
Cooks and creates a tetrahedron mesh without going through a stream.
Definition Cooking.cpp:85
virtual PxSoftBodyMesh * createSoftBodyMesh(const PxTetrahedronMeshDesc &simulationMeshDesc, const PxTetrahedronMeshDesc &collisionMeshDesc, const PxSoftBodySimulationDataDesc &softbodyDataDesc, PxInsertionCallback &insertionCallback) const
Cooks and creates a softbody mesh without going through a stream.
Definition Cooking.cpp:129
virtual const PxCookingParams & getParams() const
Gets cooking parameters.
Definition Cooking.cpp:45
virtual bool cookHeightField(const PxHeightFieldDesc &desc, PxOutputStream &stream) const
Cooks a heightfield. The results are written to the stream.
Definition Cooking.cpp:163
virtual PxSoftBodyMesh * assembleSoftBodyMesh(PxTetrahedronMeshData &simulationMesh, PxSoftBodySimulationData &simulationData, PxTetrahedronMeshData &collisionMesh, PxSoftBodyCollisionData &collisionData, PxCollisionMeshMappingData &mappingData, PxInsertionCallback &insertionCallback) const
Bundles all data required for softbody simulation.
Definition Cooking.cpp:118
virtual void release()
Closes this instance of the interface.
Definition Cooking.cpp:59
virtual bool platformMismatch() const
Checks endianness is the same between cooking & target platforms.
Definition Cooking.cpp:52
virtual bool cookTetrahedronMesh(const PxTetrahedronMeshDesc &meshDesc, PxOutputStream &stream) const
Cooks a tetrahedron mesh. The results are written to the stream.
Definition Cooking.cpp:90
virtual PxInsertionCallback & getStandaloneInsertionCallback()
Gets standalone object insertion interface.
Definition Cooking.cpp:187
virtual PxCollisionMeshMappingData * computeModelsMapping(PxTetrahedronMeshData &simulationMesh, const PxTetrahedronMeshData &collisionMesh, const PxSoftBodyCollisionData &collisionData, const PxBoundedData *vertexToTet) const
Computes the mapping between collision and simulation mesh.
Definition Cooking.cpp:103
virtual bool cookBVH(const PxBVHDesc &desc, PxOutputStream &stream) const
Cooks a bounding volume hierarchy. The results are written to the stream.
Definition Cooking.cpp:175
virtual bool cookConvexMesh(const PxConvexMeshDesc &desc, PxOutputStream &stream, PxConvexMeshCookingResult::Enum *condition) const
Cooks a convex mesh. The results are written to the stream.
Definition Cooking.cpp:138
Abstract base class for an application defined memory allocator that can be used by the Nv library.
Definition PxAllocatorCallback.h:53
Descriptor class for #PxBVH.
Definition PxBVHDesc.h:51
Class representing a bounding volume hierarchy.
Definition PxBVH.h:63
Contains information about how to update the collision mesh's vertices given a deformed simulation te...
Definition PxTetrahedronMesh.h:283
Conbines PxTetrahedronMeshData and PxSoftBodyCollisionData.
Definition PxTetrahedronMesh.h:330
Descriptor class for #PxConvexMesh.
Definition PxConvexMeshDesc.h:156
A convex mesh.
Definition PxConvexMesh.h:83
Provides methods to cook (where cooking means to prepare the data and convert it to the right format ...
Definition PxCooking.h:337
Descriptor class for #PxHeightField.
Definition PxHeightFieldDesc.h:53
A height field class.
Definition PxHeightField.h:84
Callback interface that permits TriangleMesh, Heightfield, ConvexMesh or BVH to be used directly with...
Definition PxInsertionCallback.h:57
Output stream class for I/O.
Definition PxIO.h:114
A structure describing a triangle mesh.
Definition PxSimpleTriangleMesh.h:83
Conbines PxTetrahedronMeshData and PxSoftBodyCollisionData.
Definition PxTetrahedronMesh.h:348
Stores data to accelerate collision detection of a tetrahedral mesh.
Definition PxTetrahedronMesh.h:297
A softbody mesh, containing structures to store collision shape, simulation shape and deformation sta...
Definition PxTetrahedronMesh.h:214
‍**
Definition PxTetrahedronMeshDesc.h:194
Stores data to compute and store the state of a deformed tetrahedral mesh.
Definition PxTetrahedronMesh.h:319
Contains raw geometry information describing the tetmesh's vertices and its elements (tetrahedra)
Definition PxTetrahedronMesh.h:308
Descriptor class for #PxTetrahedronMesh (contains only pure geometric data).
Definition PxTetrahedronMeshDesc.h:52
A tetramedron mesh, also called a 'tetrahedron soup'.
Definition PxTetrahedronMesh.h:115
Descriptor class for #PxTriangleMesh.
Definition PxTriangleMeshDesc.h:55
A triangle mesh, also called a 'polygon soup'.
Definition PxTriangleMesh.h:118
Definition PxUserAllocated.h:43
3 Element vector class.
Definition PxVec3.h:50
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition PxGeometryInternal.h:92
Definition PxCoreUtilityTypes.h:96
Enum
Definition PxCooking.h:63
Structure describing parameters affecting mesh cooking.
Definition PxCooking.h:185
Polygon data.
Definition PxConvexMesh.h:50
Enum
Definition PxCooking.h:112
Definition PxGeometryInternal.h:46