RavEngine
Loading...
Searching...
No Matches
GuCookingConvexMeshBuilder.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 GU_COOKING_CONVEX_MESH_BUILDER_H
30#define GU_COOKING_CONVEX_MESH_BUILDER_H
31
32#include "cooking/PxCooking.h"
33
34#include "GuConvexMeshData.h"
35#include "GuCookingConvexPolygonsBuilder.h"
36#include "GuSDF.h"
37
38namespace physx
39{
40 class BigConvexData;
41 namespace Gu
42 {
43 struct ConvexHullInitData;
44 }
45
47 // Convex mesh builder, creates the convex mesh from given polygons and creates internal data
49 {
50 public:
51 ConvexMeshBuilder(const bool buildGRBData);
53
54 // loads the computed or given convex hull from descriptor.
55 // the descriptor does contain polygons directly, triangles are not allowed
56 bool build(const PxConvexMeshDesc&, PxU32 gaussMapVertexLimit, bool validateOnly = false, ConvexHullLib* hullLib = NULL);
57
58 // save the convex mesh into stream
59 bool save(PxOutputStream& stream, bool platformMismatch) const;
60
61 // copy the convex mesh into internal convex mesh, which can be directly used then
62 bool copy(Gu::ConvexHullInitData& convexData);
63
64 // loads the convex mesh from given polygons
65 bool loadConvexHull(const PxConvexMeshDesc&, ConvexHullLib* hullLib);
66
67 // computed hull polygons from given triangles
68 bool computeHullPolygons(const PxU32& nbVerts,const PxVec3* verts, const PxU32& nbTriangles, const PxU32* triangles, PxAllocatorCallback& inAllocator,
69 PxU32& outNbVerts, PxVec3*& outVertices, PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& polygons);
70
71 // compute big convex data
72 bool computeGaussMaps();
73
74 // compute mass, inertia tensor
75 void computeMassInfo(bool lowerPrecision);
76// TEST_INTERNAL_OBJECTS
77 // internal objects
78 void computeInternalObjects();
79//~TEST_INTERNAL_OBJECTS
80
81 void computeSDF(const PxConvexMeshDesc& desc);
82
83 // set big convex data
84 void setBigConvexData(BigConvexData* data) { mBigConvexData = data; }
85
86 mutable ConvexPolygonsBuilder hullBuilder;
87
88 protected:
89 Gu::ConvexHullData mHullData;
90 Gu::SDF* mSdfData;
92 PxReal mMass; //this is mass assuming a unit density that can be scaled by instances!
93 PxMat33 mInertia; //in local space of mesh!
94
95 };
96
97}
98
99#endif
Definition GuBigConvexData2.h:42
Definition GuCookingConvexHullLib.h:40
Definition GuCookingConvexMeshBuilder.h:49
BigConvexData * mBigConvexData
optional, only for large meshes! PT: redundant with ptr in chull data? Could also be end of other buf...
Definition GuCookingConvexMeshBuilder.h:91
Definition GuCookingConvexPolygonsBuilder.h:40
Represents a signed distance field.
Definition GuSDF.h:88
Abstract base class for an application defined memory allocator that can be used by the Nv library.
Definition PxAllocatorCallback.h:53
Descriptor class for #PxConvexMesh.
Definition PxConvexMeshDesc.h:156
3x3 matrix class
Definition PxMat33.h:91
Output stream class for I/O.
Definition PxIO.h:114
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 GuConvexMeshData.h:109
Definition GuConvexMesh.h:67
Polygon data.
Definition PxConvexMesh.h:50