PxCooking.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_COOKING_H
32 #define PX_COOKING_H
33 
38 #include "cooking/Pxc.h"
39 
42 #include "cooking/PxMidphaseDesc.h"
46 
47 #if !PX_DOXYGEN
48 namespace physx
49 {
50 #endif
51 
53 class PxFoundation;
54 
59 {
60  enum Enum
61  {
66 
73 
82 
86  eFAILURE
87  };
88 };
89 
92 {
93  enum Enum
94  {
100  eQUICKHULL
101  };
102 };
103 
108 {
109  enum Enum
110  {
114  eSUCCESS = 0,
115 
120 
124  eFAILURE
125  };
126 };
127 
135 {
136  enum Enum
137  {
141  eWELD_VERTICES = 1 << 0,
142 
151  eDISABLE_CLEAN_MESH = 1 << 1,
152 
156  eDISABLE_ACTIVE_EDGES_PRECOMPUTE = 1 << 2,
157 
163  eFORCE_32BIT_INDICES = 1 << 3
164  };
165 };
166 
168 
176 {
190 
212 
221 
230 
238 
245 
254 
261 
278 
287 
296 
298  areaTestEpsilon (0.06f*sc.length*sc.length),
299  planeTolerance (0.0007f),
300  convexMeshCookingType (PxConvexMeshCookingType::eQUICKHULL),
301  suppressTriangleMeshRemapTable (false),
302  buildTriangleAdjacencies (false),
303  buildGPUData (false),
304  scale (sc),
305  meshPreprocessParams (0),
306  meshWeldTolerance (0.f),
307  gaussMapLimit (32)
308  {
309  }
310 };
311 
313 {
314 public:
323  virtual void release() = 0;
324 
332  virtual void setParams(const PxCookingParams& params) = 0;
333 
341  virtual const PxCookingParams& getParams() const = 0;
342 
348  virtual bool platformMismatch() const = 0;
349 
366  virtual bool cookTriangleMesh(const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
367 
368 
381  virtual PxTriangleMesh* createTriangleMesh(const PxTriangleMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback, PxTriangleMeshCookingResult::Enum* condition = NULL) const = 0;
382 
396  virtual bool validateTriangleMesh(const PxTriangleMeshDesc& desc) const = 0;
397 
398 
418  virtual bool cookConvexMesh(const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
419 
435  virtual PxConvexMesh* createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsInsertionCallback& insertionCallback, PxConvexMeshCookingResult::Enum* condition = NULL) const = 0;
436 
450  virtual bool validateConvexMesh(const PxConvexMeshDesc& desc) const = 0;
451 
452 
474  virtual bool computeHullPolygons(const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback, PxU32& nbVerts, PxVec3*& vertices,
475  PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons) const = 0;
476 
491  virtual bool cookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream) const = 0;
492 
502  virtual PxHeightField* createHeightField(const PxHeightFieldDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
503 
516  virtual bool cookBVHStructure(const PxBVHStructureDesc& desc, PxOutputStream& stream) const = 0;
517 
532  virtual PxBVHStructure* createBVHStructure(const PxBVHStructureDesc& desc, PxPhysicsInsertionCallback& insertionCallback) const = 0;
533 protected:
534  virtual ~PxCooking(){}
535 };
536 
537 #if !PX_DOXYGEN
538 } // namespace physx
539 #endif
540 
559  physx::PxFoundation& foundation,
560  const physx::PxCookingParams& params);
561 
563 #endif
Definition: GuContactBuffer.h:37
PxMidphaseDesc midphaseDesc
Controls the desired midphase desc structure for triangle meshes.
Definition: PxCooking.h:286
Descriptor class for PxTriangleMesh.
Definition: PxTriangleMeshDesc.h:54
PxFlags< PxMeshPreprocessingFlag::Enum, PxU32 > PxMeshPreprocessingFlags
Definition: PxCooking.h:167
Convex mesh cooking succeeded.
Definition: PxCooking.h:65
bool buildGPUData
When true, addigional information required for GPU-accelerated rigid body simulation is created...
Definition: PxCooking.h:244
Enum
Definition: PxCooking.h:136
Polygon data.
Definition: PxConvexMesh.h:51
#define PX_PHYSX_COOKING_API
Definition: Pxc.h:50
PxReal meshWeldTolerance
Mesh weld tolerance. If mesh welding is enabled, this controls the distance at which vertices are wel...
Definition: PxCooking.h:277
bool suppressTriangleMeshRemapTable
When true, the face remap table is not created. This saves a significant amount of memory...
Definition: PxCooking.h:229
Descriptor class for PxBVHStructure.
Definition: PxBVHStructureDesc.h:53
Structure describing parameters affecting midphase mesh structure.
Definition: PxMidphaseDesc.h:52
float PxReal
Definition: PxSimpleTypes.h:78
#define PX_C_EXPORT
Definition: Pxc.h:54
a triangle is too large for well-conditioned results. Tessellate the mesh for better behavior...
Definition: PxCooking.h:119
#define PX_CALL_CONV
Definition: PxPreprocessor.h:315
uint32_t PxU32
Definition: PxSimpleTypes.h:71
Descriptor class for PxHeightField.
Definition: PxHeightFieldDesc.h:54
Structure describing parameters affecting mesh cooking.
Definition: PxCooking.h:175
A triangle mesh, also called a &#39;polygon soup&#39;.
Definition: PxTriangleMesh.h:126
bool buildTriangleAdjacencies
When true, the triangle adjacency information is created. You can get the adjacency triangles for a g...
Definition: PxCooking.h:237
PxTolerancesScale scale
Tolerance scale is used to check if cooked triangles are not too huge. This check will help with simu...
Definition: PxCooking.h:253
PX_C_EXPORT PX_PHYSX_COOKING_API physx::PxCooking *PX_CALL_CONV PxCreateCooking(physx::PxU32 version, physx::PxFoundation &foundation, const physx::PxCookingParams &params)
Create an instance of the cooking interface.
A convex mesh.
Definition: PxConvexMesh.h:84
Enum
Definition: PxCooking.h:109
Convex mesh cooking succeeded, but the algorithm has reached the 255 polygons limit. The produced hull does not contain all input vertices. Try to simplify the input vertices or try to use the eINFLATE_CONVEX or the eQUANTIZE_INPUT flags.
Definition: PxCooking.h:81
Output stream class for I/O.
Definition: PxIO.h:114
float planeTolerance
Plane tolerance used in convex hull computation.
Definition: PxCooking.h:211
PxU8 mesh[sizeof(PxTriangleMeshGeometry)]
Definition: PxGeometryHelpers.h:221
Foundation SDK singleton class.
Definition: PxFoundation.h:51
PxU32 gaussMapLimit
Vertex limit beyond which additional acceleration structures are computed for each convex mesh...
Definition: PxCooking.h:295
Enum
Definition: PxCooking.h:60
float areaTestEpsilon
Zero-size area epsilon used in convex hull computation.
Definition: PxCooking.h:189
A height field class.
Definition: PxHeightField.h:85
Result from convex cooking.
Definition: PxCooking.h:58
Enumeration for convex mesh cooking algorithms.
Definition: PxCooking.h:91
virtual ~PxCooking()
Definition: PxCooking.h:534
PxCookingParams(const PxTolerancesScale &sc)
Definition: PxCooking.h:297
Result from triangle mesh cooking.
Definition: PxCooking.h:107
Definition: PxCooking.h:312
Convex mesh cooking failed, algorithm couldn&#39;t find 4 initial vertices without a small triangle...
Definition: PxCooking.h:72
Class to define the scale at which simulation runs. Most simulation tolerances are calculated in term...
Definition: PxTolerancesScale.h:56
PxConvexMeshCookingType::Enum convexMeshCookingType
Convex hull creation algorithm.
Definition: PxCooking.h:220
Abstract base class for an application defined memory allocator that can be used by the Nv library...
Definition: PxAllocatorCallback.h:52
Enum
Definition: PxCooking.h:93
Enum for the set of mesh pre-processing parameters.
Definition: PxCooking.h:134
PxMeshPreprocessingFlags meshPreprocessParams
Mesh pre-processing parameters. Used to control options like whether the mesh cooking performs vertex...
Definition: PxCooking.h:260
Descriptor class for PxConvexMesh.
Definition: PxConvexMeshDesc.h:155
Callback interface that permits PxCooking to insert a TriangleMesh, HeightfieldMesh or ConvexMesh dir...
Definition: PxPhysicsInsertionCallback.h:60
uint32_t PxU32
Definition: Px.h:48
Class representing the bounding volume hierarchy structure.
Definition: PxBVHStructure.h:57
3 Element vector class.
Definition: PxVec3.h:49
A structure describing a triangle mesh.
Definition: PxSimpleTriangleMesh.h:84