Main Page Class List Class Members

NvBlastExtRT.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27
28
29 #ifndef NVBLASTEXTRT_H
30 #define NVBLASTEXTRT_H
31
32 #include <cinttypes>
33 #include <NvBlastTypes.h>
34 #include <NvCTypes.h>
35
36
37 //#define USE_MERGED_MESH
38
39
40 #define BLASTRT_MAX_VERTICES 262144
41 #define BLASTRT_MAX_EDGES_PER_CHUNK 16384
42 #define BLASTRT_MAX_CHUNKS 256
43
44 namespace Nv
45 {
46 namespace Blast
47 {
48 struct Vertex;
49 class Mesh;
50 class SpatialAccelerator;
51 class VertexWelding;
52 struct DamagePattern;
53
54 struct FacetFacetResult
55 {
56 uint32_t parentFacet;
57 uint32_t adjacentFacet;
58 uint32_t parentEdge;
59 int32_t status;
60 uint32_t pIdx;
61
62 bool operator<(const FacetFacetResult& in) const
63 {
64 return parentFacet < in.parentFacet;
65 }
66 };
67
68 struct BooleanResultEdge
69 {
70 uint32_t start;
71 uint32_t end;
72 int32_t parentFacet;
73 int32_t adjacentFacet = -1;
74
75 BooleanResultEdge getInversed()
76 {
77 BooleanResultEdge ret;
78 ret.start = end;
79 ret.end = start;
80 ret.parentFacet = parentFacet;
81 ret.adjacentFacet = adjacentFacet;
82 return ret;
83 }
84 };
85
86 struct BooleanToolOutputData
87 {
88 virtual void release() = 0;
89
90 //set edges, vertices and ffResult counters to 0
91 virtual void reset() = 0;
92 virtual void resetEdges() = 0;
93
94 virtual void copyVerticesAndResults(const BooleanToolOutputData* other) = 0;
95
96 virtual uint32_t edgesCount() const = 0;
97 virtual uint32_t verticesCount() const = 0;
98 virtual uint32_t ffResultCount() const = 0;
99
100 //Thread safe add, return index in buffer
101 virtual uint32_t addEdge(const BooleanResultEdge&) = 0;
102 virtual uint32_t addVertex(const Vertex&) = 0;
103 virtual uint32_t addFfResult(const FacetFacetResult&) = 0;
104
105 //Thread safe, increment counter and return reference to last element
106 virtual BooleanResultEdge& getNewEdge() = 0;
107 virtual Vertex& getNewVertex() = 0;
108 virtual FacetFacetResult& getNewFfResult() = 0;
109
110 //User allocated buffers should have size more than return values of above function
111 BooleanResultEdge* edges = nullptr;
112 Vertex* vertices = nullptr;
113 FacetFacetResult* ffResult = nullptr;
114 };
115
120 class Fracturer
121 {
122 public:
123 virtual void release() = 0;
124 };
125
126 class MeshGenerator
127 {
128 public:
129 virtual void release() = 0;
130 };
131
132 struct FractureDesc
133 {
134 Fracturer* fr = nullptr;
135 const Mesh* model = nullptr;
136 const Mesh* cell = nullptr;
137 SpatialAccelerator* modelAccel = nullptr;
138 SpatialAccelerator* cellAccel = nullptr;
139 DamagePattern* pattern = nullptr;
140 BooleanToolOutputData* outputData = nullptr;
141 uint32_t chunkId;
142 };
143
144 struct PerTriangleAdditionalData
145 {
146 int32_t materialIndex;
147 int32_t smoothingGroup;
148 };
149
150 struct MeshDesc
151 {
152 MeshGenerator* tr = nullptr;
153 const BooleanResultEdge* bEdges = nullptr;
154 uint32_t edesCount = 0;
155 const Vertex* inVertices = nullptr;
156 const Mesh* meshA = nullptr; // used to gather additional data from source mesh, for example material ID
157 const Mesh* meshB = nullptr;
158 };
159
160 class FractureRT
161 {
162 public:
163
164 struct Stage
165 {
166 enum
167 {
168 FACET_FACET_TEST = 1,
169 RETAIN_FROM_FRACTURED_MESH = 2,
170 RETAIN_FROM_PATTERN = 4,
171
172 ALL = 0xFFFFFFFF
173 };
174 };
175
176 virtual void release() = 0;
177 virtual void processMesh(DamagePattern* pattern, const Mesh* msh) = 0;
178 virtual uint32_t getResultChunkCount() = 0;
179 virtual Vertex* getVertexBuffer() = 0;
180 virtual uint32_t* getIndexBuffer() = 0;
181 virtual uint32_t* getVertexOffset() = 0;
182 virtual uint32_t* getIndexOffset() = 0;
183 virtual PerTriangleAdditionalData* getPerTriangleData() = 0;
184 virtual void dumpChunksToObj(const char* path) = 0;
185 };
186
187 enum PatternFacetType { GOOD_FACET = 0, INFINITE_FACET = 0xffffff };
188
189
193 struct ChunkGraphLink
194 {
195 ChunkGraphLink() = default;
196 ChunkGraphLink(uint32_t i, uint32_t j) : l1(i), l2(j) {};
197 uint32_t l1;
198 uint32_t l2;
199
200 bool operator<(const ChunkGraphLink& lk) const;
201 bool operator<(const uint32_t in) const;
202 };
203
204 struct ChunkGraph
205 {
206 virtual void eraseNode(uint32_t index) = 0;
207 virtual void release() = 0;
208
209 ChunkGraphLink* links = nullptr;
210 uint32_t* dirtyChunks = nullptr;
211 uint32_t linksCount = 0;
212 uint32_t dirtyChunksCount = 0;
213 uint32_t newlyAddedCount = 0;
214 uint32_t maxLinksCount = 0;
215 };
216
217 }
218 }
219
220
224 NVBLAST_API Nv::Blast::FractureRT* NvBlastExtRTCreateFractureRT(uint32_t threads = 1);
225
229 NVBLAST_API Nv::Blast::Fracturer* NvBlastExtRTCreateFracturer();
230
234 NVBLAST_API uint32_t NvBlastExtRTDoFracture(const Nv::Blast::FractureDesc& desc, int32_t stage = Nv::Blast::FractureRT::Stage::ALL, int32_t threadId = 0, int32_t threadCount = 1);
235
239 NVBLAST_API Nv::Blast::MeshGenerator* NvBlastExtRTCreateMeshGenerator();
240
244 NVBLAST_API uint32_t NvBlastExtRTBuildMesh(Nv::Blast::MeshDesc dsc, Nv::Blast::Vertex* outVertices, uint32_t& vCount, uint32_t* indices, Nv::Blast::PerTriangleAdditionalData* adata, uint32_t maxICount, uint32_t maxVCount);
245
249 NVBLAST_API uint32_t NvBlastExtRTGetChunksToUnite(Nv::Blast::DamagePattern* pattern, const Nv::Blast::Vertex* vertices, const uint32_t* voffsets, uint32_t chunksCount, uint32_t* chunksToUnite);
250
254 NVBLAST_API uint32_t NvBlastExtRTDetectIslands(Nv::Blast::Vertex* vertices, uint32_t* offsets, NvcBounds3* bounds, uint32_t chunkCount, Nv::Blast::ChunkGraph* graph, uint32_t* islandChunks, uint32_t* islandOffsets);
255
259 NVBLAST_API Nv::Blast::ChunkGraph* NvBlastExtRTCreateChunkGraph(uint32_t maxLinksCount = 4096);
260
264 NVBLAST_API void NvBlastExtRTCookMergedMesh(Nv::Blast::DamagePattern* pattern);
265
266
267
268 #endif // ifndef NVBLASTEXTRT_H
NvBlastExtRTCreateMeshGenerator
NVBLAST_API Nv::Blast::MeshGenerator * NvBlastExtRTCreateMeshGenerator()
NvBlastExtRTCreateFractureRT
NVBLAST_API Nv::Blast::FractureRT * NvBlastExtRTCreateFractureRT(uint32_t threads=1)
Nv::Blast::ChunkGraph
Definition: NvBlastExtRT.h:204
Nv::Blast::PatternFacetType
PatternFacetType
Definition: NvBlastExtRT.h:187
Nv::Blast::BooleanResultEdge
Definition: NvBlastExtRT.h:68
Nv::Blast::MeshDesc
Definition: NvBlastExtRT.h:150
Nv::Blast::BooleanResultEdge::parentFacet
int32_t parentFacet
Definition: NvBlastExtRT.h:72
Nv::Blast::PerTriangleAdditionalData
Definition: NvBlastExtRT.h:144
NvBlastTypes.h
Nv::Blast::SpatialAccelerator
Definition: NvBlastExtAuthoringAccelerator.h:47
NvBlastExtRTBuildMesh
NVBLAST_API uint32_t NvBlastExtRTBuildMesh(Nv::Blast::MeshDesc dsc, Nv::Blast::Vertex *outVertices, uint32_t &vCount, uint32_t *indices, Nv::Blast::PerTriangleAdditionalData *adata, uint32_t maxICount, uint32_t maxVCount)
Nv::Blast::Mesh
Definition: NvBlastExtAuthoringMesh.h:42
Nv::Blast::BooleanResultEdge::adjacentFacet
int32_t adjacentFacet
Definition: NvBlastExtRT.h:73
Nv::Blast::FractureDesc
Definition: NvBlastExtRT.h:132
NvBlastExtRTGetChunksToUnite
NVBLAST_API uint32_t NvBlastExtRTGetChunksToUnite(Nv::Blast::DamagePattern *pattern, const Nv::Blast::Vertex *vertices, const uint32_t *voffsets, uint32_t chunksCount, uint32_t *chunksToUnite)
Nv::Blast::BooleanResultEdge::start
uint32_t start
Definition: NvBlastExtRT.h:70
Nv::Blast::INFINITE_FACET
Definition: NvBlastExtRT.h:187
Nv::Blast::FacetFacetResult::operator<
bool operator<(const FacetFacetResult &in) const
Definition: NvBlastExtRT.h:62
Nv::Blast::BooleanResultEdge::end
uint32_t end
Definition: NvBlastExtRT.h:71
Nv::Blast::FacetFacetResult::adjacentFacet
uint32_t adjacentFacet
Definition: NvBlastExtRT.h:57
Nv::Blast::BooleanResultEdge::getInversed
BooleanResultEdge getInversed()
Definition: NvBlastExtRT.h:75
Nv::Blast::DamagePattern
Definition: NvBlastExtAuthoringPatternGenerator.h:85
Nv::Blast::FacetFacetResult::status
int32_t status
Definition: NvBlastExtRT.h:59
Nv::Blast::FacetFacetResult::parentFacet
uint32_t parentFacet
Definition: NvBlastExtRT.h:56
Nv::Blast::BooleanToolOutputData
Definition: NvBlastExtRT.h:86
Nv::Blast::FacetFacetResult::pIdx
uint32_t pIdx
Definition: NvBlastExtRT.h:60
Nv::Blast::FractureDesc::chunkId
uint32_t chunkId
Definition: NvBlastExtRT.h:141
Nv::Blast::GOOD_FACET
Definition: NvBlastExtRT.h:187
Nv::Blast::FractureRT::Stage::ALL
Definition: NvBlastExtRT.h:172
Nv::Blast::PerTriangleAdditionalData::materialIndex
int32_t materialIndex
Definition: NvBlastExtRT.h:146
NVBLAST_API
#define NVBLAST_API
Definition: NvBlastPreprocessor.h:37
NvBlastExtRTCreateFracturer
NVBLAST_API Nv::Blast::Fracturer * NvBlastExtRTCreateFracturer()
Nv::Blast::FractureRT
Definition: NvBlastExtRT.h:160
NvcBounds3
Definition: NvCTypes.h:92
NvBlastExtRTCookMergedMesh
NVBLAST_API void NvBlastExtRTCookMergedMesh(Nv::Blast::DamagePattern *pattern)
Nv::Blast::ChunkGraphLink
Definition: NvBlastExtRT.h:193
Nv::Blast::ChunkGraphLink::l1
uint32_t l1
Definition: NvBlastExtRT.h:196
Nv::Blast::PerTriangleAdditionalData::smoothingGroup
int32_t smoothingGroup
Definition: NvBlastExtRT.h:147
NvBlastExtRTDoFracture
NVBLAST_API uint32_t NvBlastExtRTDoFracture(const Nv::Blast::FractureDesc &desc, int32_t stage=Nv::Blast::FractureRT::Stage::ALL, int32_t threadId=0, int32_t threadCount=1)
Nv::Blast::FacetFacetResult::parentEdge
uint32_t parentEdge
Definition: NvBlastExtRT.h:58
Nv::Blast::FacetFacetResult
Definition: NvBlastExtRT.h:54
Nv::Blast::Vertex
Definition: NvBlastExtAuthoringTypes.h:67
Nv::Blast::ChunkGraphLink::l2
uint32_t l2
Definition: NvBlastExtRT.h:198
Nv::Blast::FractureRT::Stage
Definition: NvBlastExtRT.h:164
Nv::Blast::MeshGenerator
Definition: NvBlastExtRT.h:126
Nv::Blast::Fracturer
Definition: NvBlastExtRT.h:120
Nv
Definition: NvBlastArray.h:37
NvBlastExtRTDetectIslands
NVBLAST_API uint32_t NvBlastExtRTDetectIslands(Nv::Blast::Vertex *vertices, uint32_t *offsets, NvcBounds3 *bounds, uint32_t chunkCount, Nv::Blast::ChunkGraph *graph, uint32_t *islandChunks, uint32_t *islandOffsets)
NvBlastExtRTCreateChunkGraph
NVBLAST_API Nv::Blast::ChunkGraph * NvBlastExtRTCreateChunkGraph(uint32_t maxLinksCount=4096)
NvCTypes.h