Main Page Class List Class Members

NvBlastExtAuthoringFractureToolImpl.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 #ifndef NVBLASTAUTHORINGFRACTURETOOLIMPL_H
29 #define NVBLASTAUTHORINGFRACTURETOOLIMPL_H
30
31 #include "NvBlastExtAuthoringFractureTool.h"
32 #include "NvBlastExtAuthoringMesh.h"
33 #include <vector>
34 #include <set>
35
36 namespace Nv
37 {
38 namespace Blast
39 {
40
41 class SpatialAccelerator;
42 class Triangulator;
43
44
48 class VoronoiSitesGeneratorImpl : public VoronoiSitesGenerator
49 {
50 public:
51
59 VoronoiSitesGeneratorImpl(const Mesh* mesh, RandomGeneratorBase* rnd);
60 ~VoronoiSitesGeneratorImpl();
61
62 void release() override;
63
67 void setBaseMesh(const Mesh* m) override;
68
75 uint32_t getVoronoiSites(const NvcVec3*& sites) override;
76
81 void addSite(const NvcVec3& site) override;
86 void uniformlyGenerateSitesInMesh(uint32_t numberOfSites) override;
87
94 void clusteredSitesGeneration(uint32_t numberOfClusters, uint32_t sitesPerCluster, float clusterRadius) override;
95
106 void radialPattern(const NvcVec3& center, const NvcVec3& normal, float radius, int32_t angularSteps, int32_t radialSteps, float angleOffset = 0.0f, float variability = 0.0f) override;
107
114 void generateInSphere(const uint32_t count, const float radius, const NvcVec3& center) override;
119 void setStencil(const Mesh* stencil) override;
123 void clearStencil() override;
124
131 void deleteInSphere(const float radius, const NvcVec3& center, const float eraserProbability = 1) override;
132
133 private:
134 std::vector <NvcVec3> mGeneratedSites;
135 const Mesh* mMesh;
136 const Mesh* mStencil;
137 RandomGeneratorBase* mRnd;
138 SpatialAccelerator* mAccelerator;
139 };
140
141
142
146 class FractureToolImpl : public FractureTool
147 {
148
149 public:
150
154 FractureToolImpl()
155 {
156 mPlaneIndexerOffset = 1;
157 mChunkIdCounter = 0;
158 mRemoveIslands = false;
159 mInteriorMaterialId = kMaterialInteriorId;
160 }
161
162 ~FractureToolImpl()
163 {
164 reset();
165 }
166
167 void release() override;
168
172 void reset() override;
173
177 void setInteriorMaterialId(int32_t materialId) override;
178
182 int32_t getInteriorMaterialId() const override;
183
187 void replaceMaterialId(int32_t oldMaterialId, int32_t newMaterialId) override;
188
192 void setSourceMesh(const Mesh* mesh) override;
193
197 int32_t setChunkMesh(const Mesh* mesh, int32_t parentId) override;
198
202 Mesh* createChunkMesh(int32_t chunkId) override;
203
208 void getTransformation(NvcVec3& offset, float& scale) override;
209
210
219 int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const NvcVec3* cellPoints, bool replaceChunk) override;
220
232 int32_t voronoiFracturing(uint32_t chunkId, uint32_t cellCount, const NvcVec3* cellPoints, const NvcVec3& scale, const NvcQuat& rotation, bool replaceChunk) override;
233
234
245 int32_t slicing(uint32_t chunkId, const SlicingConfiguration& conf, bool replaceChunk, RandomGeneratorBase* rnd) override;
246
247
260 int32_t cut(uint32_t chunkId, const NvcVec3& normal, const NvcVec3& position, const NoiseConfiguration& noise, bool replaceChunk, RandomGeneratorBase* rnd) override;
261
272 int32_t cutout(uint32_t chunkId, CutoutConfiguration conf, bool replaceChunk, RandomGeneratorBase* rnd) override;
273
274
278 void finalizeFracturing() override;
279
280 uint32_t getChunkCount() const override;
281
285 const ChunkInfo& getChunkInfo(int32_t chunkIndex) override;
286
294 float getMeshOverlap(const Mesh& meshA, const Mesh& meshB) override;
295
303 uint32_t getBaseMesh(int32_t chunkIndex, Triangle*& output) override;
304
312 uint32_t updateBaseMesh(int32_t chunkIndex, Triangle* output) override;
313
319 int32_t getChunkIndex(int32_t chunkId) override;
320
326 int32_t getChunkId(int32_t chunkIndex) override;
327
333 int32_t getChunkDepth(int32_t chunkId) override;
334
342 uint32_t getChunksIdAtDepth(uint32_t depth, int32_t*& chunkIds) override;
343
344
355 uint32_t getBufferedBaseMeshes(Vertex*& vertexBuffer, uint32_t*& indexBuffer, uint32_t*& indexBufferOffsets) override;
356
361 void setRemoveIslands(bool isRemoveIslands) override;
362
368 int32_t islandDetectionAndRemoving(int32_t chunkId, bool createAtNewDepth = false) override;
369
374 bool isMeshContainOpenEdges(const Mesh* input) override;
375
376 bool deleteChunkSubhierarchy(int32_t chunkId, bool deleteRoot = false) override;
377
378 void uniteChunks(uint32_t threshold, uint32_t targetClusterSize,
379 const uint32_t* chunksToMerge, uint32_t mergeChunkCount,
380 const NvcVec2i* adjChunks, uint32_t adjChunksSize,
381 bool removeOriginalChunks = false) override;
382
383 bool setApproximateBonding(uint32_t chunkId, bool useApproximateBonding) override;
384
390 void fitUvToRect(float side, uint32_t chunkId) override;
391
396 void fitAllUvToRect(float side) override;
397
398
399
400 private:
401 bool isAncestorForChunk(int32_t ancestorId, int32_t chunkId);
402 int32_t slicingNoisy(uint32_t chunkId, const SlicingConfiguration& conf, bool replaceChunk, RandomGeneratorBase* rnd);
403 uint32_t stretchGroup(const std::vector<uint32_t>& group, std::vector<std::vector<uint32_t>>& graph);
404 void rebuildAdjGraph(const std::vector<uint32_t>& chunksToRebuild, const NvcVec2i* adjChunks, uint32_t adjChunksSize,
405 std::vector<std::vector<uint32_t> >& chunkGraph);
406 void fitAllUvToRect(float side, std::set<uint32_t>& mask);
407 void markLeaves();
408
412 uint32_t createNewChunk(uint32_t parentId);
413
414
415 protected:
419 float mScaleFactor;
420 NvcVec3 mOffset;
421
422 /* Chunk mesh wrappers */
423 std::vector<Triangulator*> mChunkPostprocessors;
424
425
426
427 int64_t mPlaneIndexerOffset;
428 int32_t mChunkIdCounter;
429 std::vector<ChunkInfo> mChunkData;
430
431 bool mRemoveIslands;
432 int32_t mInteriorMaterialId;
433 };
434
435 void findCellBasePlanes(const std::vector<NvcVec3>& sites, std::vector<std::vector<int32_t> >& neighboors);
436 Mesh* getCellMesh(class BooleanEvaluator& eval, int32_t planeIndexerOffset, int32_t cellId, const std::vector<NvcVec3>& sites, std::vector < std::vector<int32_t> >& neighboors, int32_t interiorMaterialId, NvcVec3 origin);
437
438 } // namespace Blast
439 } // namespace Nv
440
441
442 #endif // ifndef NVBLASTAUTHORINGFRACTURETOOLIMPL_H
Nv::Blast::SlicingConfiguration
Definition: NvBlastExtAuthoringFractureTool.h:107
Nv::Blast::VoronoiSitesGeneratorImpl::generateInSphere
void generateInSphere(const uint32_t count, const float radius, const NvcVec3 &center) override
Nv::Blast::ChunkInfo
Definition: NvBlastExtAuthoringFractureTool.h:47
Nv::Blast::VoronoiSitesGeneratorImpl::getVoronoiSites
uint32_t getVoronoiSites(const NvcVec3 *&sites) override
Nv::Blast::VoronoiSitesGeneratorImpl::addSite
void addSite(const NvcVec3 &site) override
Nv::Blast::FractureToolImpl::~FractureToolImpl
~FractureToolImpl()
Definition: NvBlastExtAuthoringFractureToolImpl.h:162
Nv::Blast::VoronoiSitesGeneratorImpl::deleteInSphere
void deleteInSphere(const float radius, const NvcVec3 &center, const float eraserProbability=1) override
Nv::Blast::VoronoiSitesGenerator
Definition: NvBlastExtAuthoringFractureTool.h:179
Nv::Blast::BooleanEvaluator
Definition: NvBlastExtAuthoringBooleanTool.h:108
Nv::Blast::VecMath::normal
NV_INLINE float normal(const float a[3], float r[3])
Definition: NvBlastMath.h:93
Nv::Blast::VoronoiSitesGeneratorImpl::setBaseMesh
void setBaseMesh(const Mesh *m) override
Nv::Blast::FractureToolImpl::mScaleFactor
float mScaleFactor
Definition: NvBlastExtAuthoringFractureToolImpl.h:419
Nv::Blast::SpatialAccelerator
Definition: NvBlastExtAuthoringAccelerator.h:47
Nv::Blast::VoronoiSitesGeneratorImpl::clearStencil
void clearStencil() override
Nv::Blast::NoiseConfiguration
Definition: NvBlastExtAuthoringFractureTool.h:79
Nv::Blast::Mesh
Definition: NvBlastExtAuthoringMesh.h:42
Nv::Blast::FractureTool
Definition: NvBlastExtAuthoringFractureTool.h:264
Nv::Blast::findCellBasePlanes
void findCellBasePlanes(const std::vector< NvcVec3 > &sites, std::vector< std::vector< int32_t > > &neighboors)
NvBlastExtAuthoringMesh.h
Nv::Blast::RandomGeneratorBase
Definition: NvBlastExtAuthoringFractureTool.h:66
Nv::Blast::VoronoiSitesGeneratorImpl::uniformlyGenerateSitesInMesh
void uniformlyGenerateSitesInMesh(uint32_t numberOfSites) override
NvBlastExtAuthoringFractureTool.h
Nv::Blast::getCellMesh
Mesh * getCellMesh(class BooleanEvaluator &eval, int32_t planeIndexerOffset, int32_t cellId, const std::vector< NvcVec3 > &sites, std::vector< std::vector< int32_t > > &neighboors, int32_t interiorMaterialId, NvcVec3 origin)
Nv::Blast::FractureToolImpl::mChunkIdCounter
int32_t mChunkIdCounter
Definition: NvBlastExtAuthoringFractureToolImpl.h:428
NvcVec2i
Definition: NvCTypes.h:106
Nv::Blast::kMaterialInteriorId
const uint32_t kMaterialInteriorId
Definition: NvBlastExtAuthoringTypes.h:42
Nv::Blast::FractureToolImpl::mChunkData
std::vector< ChunkInfo > mChunkData
Definition: NvBlastExtAuthoringFractureToolImpl.h:429
Nv::Blast::FractureToolImpl::mChunkPostprocessors
std::vector< Triangulator * > mChunkPostprocessors
Definition: NvBlastExtAuthoringFractureToolImpl.h:423
Nv::Blast::FractureToolImpl::mOffset
NvcVec3 mOffset
Definition: NvBlastExtAuthoringFractureToolImpl.h:420
Nv::Blast::CutoutConfiguration
Definition: NvBlastExtAuthoringFractureTool.h:133
Nv::Blast::Triangle
Definition: NvBlastExtAuthoringTypes.h:79
Nv::Blast::FractureToolImpl::mInteriorMaterialId
int32_t mInteriorMaterialId
Definition: NvBlastExtAuthoringFractureToolImpl.h:432
Nv::Blast::VoronoiSitesGeneratorImpl::release
void release() override
Nv::Blast::VoronoiSitesGeneratorImpl
Definition: NvBlastExtAuthoringFractureToolImpl.h:48
Nv::Blast::FractureToolImpl
Definition: NvBlastExtAuthoringFractureToolImpl.h:146
Nv::Blast::FractureToolImpl::FractureToolImpl
FractureToolImpl()
Definition: NvBlastExtAuthoringFractureToolImpl.h:154
Nv::Blast::VoronoiSitesGeneratorImpl::VoronoiSitesGeneratorImpl
VoronoiSitesGeneratorImpl(const Mesh *mesh, RandomGeneratorBase *rnd)
Nv::Blast::VoronoiSitesGeneratorImpl::radialPattern
void radialPattern(const NvcVec3 &center, const NvcVec3 &normal, float radius, int32_t angularSteps, int32_t radialSteps, float angleOffset=0.0f, float variability=0.0f) override
Nv::Blast::Vertex
Definition: NvBlastExtAuthoringTypes.h:67
Nv::Blast::VoronoiSitesGeneratorImpl::setStencil
void setStencil(const Mesh *stencil) override
Nv
Definition: NvBlastArray.h:37
NvcVec3
Definition: NvCTypes.h:49
Nv::Blast::VoronoiSitesGeneratorImpl::clusteredSitesGeneration
void clusteredSitesGeneration(uint32_t numberOfClusters, uint32_t sitesPerCluster, float clusterRadius) override
Nv::Blast::VoronoiSitesGeneratorImpl::~VoronoiSitesGeneratorImpl
~VoronoiSitesGeneratorImpl()
Nv::Blast::FractureToolImpl::mPlaneIndexerOffset
int64_t mPlaneIndexerOffset
Definition: NvBlastExtAuthoringFractureToolImpl.h:427
NvcQuat
Definition: NvCTypes.h:61
Nv::Blast::FractureToolImpl::mRemoveIslands
bool mRemoveIslands
Definition: NvBlastExtAuthoringFractureToolImpl.h:431