RavEngine
Loading...
Searching...
No Matches
GuCookingTriangleMesh.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_TRIANGLE_MESH_H
30#define GU_COOKING_TRIANGLE_MESH_H
31
32#include "GuMeshData.h"
33#include "cooking/PxCooking.h"
34
35namespace physx
36{
37 namespace Gu
38 {
39 class EdgeList;
40 }
41
43 {
44 public:
46 virtual ~TriangleMeshBuilder();
47
48 virtual PxMeshMidPhase::Enum getMidphaseID() const = 0;
49 // Called by base code when midphase structure should be built
50 virtual void createMidPhaseStructure() = 0;
51
52 // Called by base code when midphase structure should be saved
53 virtual void saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const = 0;
54 // Called by base code when mesh index format has changed and the change should be reflected in midphase structure
55 virtual void onMeshIndexFormatChange() {}
56
57 bool cleanMesh(bool validate, PxTriangleMeshCookingResult::Enum* condition);
58 void remapTopology(const PxU32* order);
59
60 void createVertMapping();
61 void createSharedEdgeData(bool buildAdjacencies, bool buildActiveEdges);
62
63 void recordTriangleIndices();
64 void createGRBMidPhaseAndData(const PxU32 originalTriangleCount);
65 void createGRBData();
66
67 bool loadFromDesc(const PxTriangleMeshDesc&, PxTriangleMeshCookingResult::Enum* condition, bool validate = false);
68
69 bool save(PxOutputStream& stream, bool platformMismatch, const PxCookingParams& params) const;
70 void checkMeshIndicesSize();
71 PX_FORCE_INLINE Gu::TriangleMeshData& getMeshData() { return mMeshData; }
72 protected:
73 //void computeLocalBounds();
74 bool importMesh(const PxTriangleMeshDesc& desc, const PxCookingParams& params, PxTriangleMeshCookingResult::Enum* condition, bool validate = false);
75
76
77 bool loadFromDescInternal(PxTriangleMeshDesc&, PxTriangleMeshCookingResult::Enum* condition, bool validate = false);
78
79 void buildInertiaTensor();
80 void buildInertiaTensorFromSDF();
81
83 Gu::EdgeList* mEdgeList;
84 const PxCookingParams& mParams;
85 Gu::TriangleMeshData& mMeshData;
86 };
87
89 {
90 public:
93
94 virtual PxMeshMidPhase::Enum getMidphaseID() const { return PxMeshMidPhase::eBVH33; }
95 virtual void createMidPhaseStructure();
96 virtual void saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const;
97
99 };
100
102 {
103 public:
105 virtual ~BV4TriangleMeshBuilder();
106
107 virtual PxMeshMidPhase::Enum getMidphaseID() const { return PxMeshMidPhase::eBVH34; }
108 virtual void createMidPhaseStructure();
109 virtual void saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const;
110 virtual void onMeshIndexFormatChange();
111
113 };
114
116 {
117 public:
118 static void createMidPhaseStructure(const PxCookingParams& params, Gu::TriangleMeshData& meshData, Gu::BV32Tree& bv32Tree);
119 static void saveMidPhaseStructure(Gu::BV32Tree* tree, PxOutputStream& stream, bool mismatch);
120 };
121
122}
123
124#endif
Definition GuCookingTriangleMesh.h:116
Definition GuCookingTriangleMesh.h:102
Definition GuBV32.h:121
Definition GuMeshData.h:273
Definition GuEdgeList.h:135
Definition GuMeshData.h:264
Definition GuMeshData.h:171
Output stream class for I/O.
Definition PxIO.h:114
Descriptor class for #PxTriangleMesh.
Definition PxTriangleMeshDesc.h:55
Definition GuCookingTriangleMesh.h:89
Definition GuCookingTriangleMesh.h:43
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Structure describing parameters affecting mesh cooking.
Definition PxCooking.h:185
Enum
Definition PxTriangleMesh.h:58
@ eBVH33
Default midphase mesh structure, as used up to PhysX 3.3 (deprecated)
Definition PxTriangleMesh.h:59
@ eBVH34
New midphase mesh structure, introduced in PhysX 3.4.
Definition PxTriangleMesh.h:60
Enum
Definition PxCooking.h:112