Main Page Class List Class Members

NvBlastExtRTGeometry.h
Go to the documentation of this file.
1 #pragma once
2 #include "NvBlastExtAuthoringTypes.h"
3 #include "NvBlastExtAuthoringInternalCommon.h"
4 #include "NvBlastExtAuthoringAccelerator.h"
5 #include "NvBlastExtRT.h"
6 #include <map>
7
8 using physx::PxVec3;
9 using physx::PxVec2;
10
11
12 namespace Nv
13 {
14 namespace Blast
15 {
16 class Mesh;
17
18 class VertexWelding
19 {
20 public:
21
22 typedef int32_t (VertexWelding::*LOCATE_CALLBACK)(const Vertex& v, uint32_t bucket, bool& isAllDataTheSame);
23
24 VertexWelding(uint32_t maxVertexCount, uint32_t maxBucketCount, float gridCellSize, float weldEpsilon, float auxEpsilon, LOCATE_CALLBACK clb);
25
26 const Vertex* getVertices() const
27 {
28 return vertex.data();
29 }
30 uint32_t getVerticesCount() const
31 {
32 return vertex.size();
33 }
34 void reset();
35 int32_t WeldVertex(const Vertex *v);
36
37 int32_t LocateVertexInBucket(const Vertex& v, uint32_t bucket, bool& isAllDataTheSame);
38
39 int32_t LocateVertexInBucketOnlyPosition(const Vertex& v, uint32_t bucket, bool& isAllDataTheSame);
40
41
42 private:
43 // Computes hash bucket index in range [0, NUM_BUCKETS-1]
44 //int32_t ComputeHashBucketIndex(const Vertex& v)
45 int32_t ComputeHashBucketIndex(int32_t x, int32_t y, int32_t z);
46
47 void AddVertexToBucket(const Vertex& v, uint32_t bucket);
48
49 std::vector<int32_t> first; // start of linked list for each bucket
50 std::vector<int32_t> next; // links each vertex to next in linked list
51 std::vector<Vertex> vertex; // unique vertices within tolerance
52
53 const uint32_t maxVertexCount; // max number of vertices that can be welded at once
54 const uint32_t maxBucketCount; // number of hash buckets to map grid cells into
55 const float gridCellSizeInv; // grid cell size; must be at least 2*WELD_EPSILON
56 const float weldEpsilon; // radius around vertex defining welding neighborhood
57 const float auxEpsilon; // epsilon for normal and uv of vertex
58
59 LOCATE_CALLBACK locateCallback;
60 };
61
62 class BooleanToolV2 : public Fracturer
63 {
64 public:
65
66 struct Mode
67 {
68 int32_t ca, cb, ci;
69 Mode() { ca = 0; cb = 0; ci = -1; };
70 Mode(int32_t a, int32_t b, int32_t c) : ca(a), cb(b), ci(c)
71 {
72 }
73
74 static Mode Intersection()
75 {
76 return Mode(0, 0, 1);
77 }
78
82 static Mode Union()
83 {
84 return Mode(1, 1, -1);
85 }
89 static Mode Difference()
90 {
91 return Mode(1, 0, -1);
92 }
93 };
94
95 BooleanToolV2();
96
97 void release();
98
103 const Mesh* mMeshA;
104 const Mesh* mMeshB;
105 SpatialAccelerator* mAccelA;
106 SpatialAccelerator* mAccelB;
107 //const PreparedMesh* mPreparedA;
108 //const PreparedMesh* mPreparedB;
109
110
114 void makeFacetFacetTests(BooleanToolOutputData* outputData, int32_t threadId, int32_t threadCount);
115 void retain(bool isA, BooleanToolOutputData* outputData, int32_t threadId, int32_t threadCount,
116 const DamagePattern* pattern = nullptr, int32_t chunk = -1);
117
121 //Nv::Blast::Mesh* getMesh();
122
123
124 private:
125
126 int32_t computeV03(const PxVec3& point);
127 int32_t computeV30(const PxVec3& point);
128
129
133 void computeRetained(const Mesh* mesh, const physx::PxBounds3& bMeshBoudning,
134 int32_t(BooleanToolV2::*computeV3)(const physx::PxVec3&), int32_t btC, int32_t btCI, int32_t parentFacetOffset,
135 BooleanToolOutputData* outputData, int32_t threadId, int32_t threadCount,
136 struct FaceOrientation* fo = nullptr, const std::vector<bool>* validAdjacentFacet = nullptr);
137
138
140
143 float* sx1;
144 float* sy1;
145 float* ex1;
146 float* ey1;
147 float* px1;
148 float* py1;
149 float* pt1;
150 float* resy1;
151 int32_t* winding1;
152 int32_t* projectedWinding1;
153
154
155 float* sx2;
156 float* sy2;
157 float* ex2;
158 float* ey2;
159 float* px2;
160 float* py2;
161 float* pt2;
162 float* resy2;
163 int32_t* winding2;
164 int32_t* projectedWinding2;
165
166 uint32_t* edgeFacetTestA;
167 uint32_t* edgeFacetTestB;
168
169
173 int32_t* edgeCrossCheckTest;
174 Vertex* edgeCrossA;
175 Vertex* edgeCrossB;
176
177 Mode mToolMode;
178 };
179
180 class TriangulatorV2 : public MeshGenerator
181 {
182 public:
183 TriangulatorV2();
184
185 void release();
186
187 uint32_t build(const BooleanResultEdge* edges, uint32_t inEdgeCount, const Vertex* inVertices, Vertex* outWeldedVrts, uint32_t& vcount, uint32_t* outTriangles, PerTriangleAdditionalData* adata, uint32_t maxTcount, const Mesh* ma, const Mesh* mb);
188
189 struct LinkedListElement
190 {
191 uint32_t point;
192 uint32_t nextPoint;
193 uint32_t prevPoint;
194 };
195
196 Vertex* weldedVertices;
197 uint32_t weldedCount;
198 uint32_t* triangleIndices;
199 uint32_t triangleCount;
200
201 private:
202
203 void triangulatePolygonWithEarClipping(ProjectionDirections dir);
204
205 LinkedListElement facetList[1024];
206 uint32_t facetListSize;
207 uint32_t pointIndicesList[1024];
208 uint32_t pointCount;
209
210 physx::PxVec2 projectedPointList[1024];
211 uint32_t projectedPointCount;
212
213 uint32_t visitedFlagValue[1024];
214 uint32_t currentFlagValue;
215
216
217
218 Edge* weldedEdges;
219
220
221 const BooleanResultEdge* mInpEdges;
222 uint32_t mInpEdgeCount;
223 uint32_t maxTriangleCount;
224
225 const Mesh* meshA;
226 const Mesh* meshB;
227
228 VertexWelding wldg;
229 };
230
231 }
232 }
233
Nv::Blast::VertexWelding
Definition: NvBlastExtRTGeometry.h:18
Nv::Blast::ProjectionDirections
ProjectionDirections
Definition: NvBlastExtAuthoringInternalCommon.h:93
Nv::Blast::VertexWelding::WeldVertex
int32_t WeldVertex(const Vertex *v)
Nv::Blast::BooleanResultEdge
Definition: NvBlastExtRT.h:68
Nv::Blast::TriangulatorV2::triangleIndices
uint32_t * triangleIndices
Definition: NvBlastExtRTGeometry.h:198
Nv::Blast::PerTriangleAdditionalData
Definition: NvBlastExtRT.h:144
Nv::Blast::TriangulatorV2::LinkedListElement
Definition: NvBlastExtRTGeometry.h:189
x
SIMD_FORCE_INLINE const btScalar & x() const
Return the x value.
Definition: btVector3.h:275
Nv::Blast::BooleanToolV2::Mode::ci
int32_t ci
Definition: NvBlastExtRTGeometry.h:68
Nv::Blast::TriangulatorV2::LinkedListElement::point
uint32_t point
Definition: NvBlastExtRTGeometry.h:191
Nv::Blast::VertexWelding::LocateVertexInBucket
int32_t LocateVertexInBucket(const Vertex &v, uint32_t bucket, bool &isAllDataTheSame)
NvBlastExtAuthoringTypes.h
Nv::Blast::SpatialAccelerator
Definition: NvBlastExtAuthoringAccelerator.h:47
Nv::Blast::Mesh
Definition: NvBlastExtAuthoringMesh.h:42
Nv::Blast::VertexWelding::getVertices
const Vertex * getVertices() const
Definition: NvBlastExtRTGeometry.h:26
Nv::Blast::BooleanToolV2::Mode::Intersection
static Mode Intersection()
Definition: NvBlastExtRTGeometry.h:74
Nv::Blast::BooleanToolV2::mMeshB
const Mesh * mMeshB
Definition: NvBlastExtRTGeometry.h:104
Nv::Blast::TriangulatorV2::weldedVertices
Vertex * weldedVertices
Definition: NvBlastExtRTGeometry.h:196
Nv::Blast::TriangulatorV2
Definition: NvBlastExtRTGeometry.h:180
Nv::Blast::DamagePattern
Definition: NvBlastExtAuthoringPatternGenerator.h:85
NvBlastExtAuthoringAccelerator.h
Nv::Blast::BooleanToolV2::Mode::Mode
Mode()
Definition: NvBlastExtRTGeometry.h:69
Nv::Blast::BooleanToolOutputData
Definition: NvBlastExtRT.h:86
Nv::Blast::TriangulatorV2::LinkedListElement::prevPoint
uint32_t prevPoint
Definition: NvBlastExtRTGeometry.h:193
y
SIMD_FORCE_INLINE const btScalar & y() const
Return the y value.
Definition: btVector3.h:277
Nv::Blast::VertexWelding::getVerticesCount
uint32_t getVerticesCount() const
Definition: NvBlastExtRTGeometry.h:30
Nv::Blast::BooleanToolV2::Mode::Union
static Mode Union()
Definition: NvBlastExtRTGeometry.h:82
Nv::Blast::BooleanToolV2::mMeshA
const Mesh * mMeshA
Definition: NvBlastExtRTGeometry.h:103
Nv::Blast::VertexWelding::LOCATE_CALLBACK
int32_t(VertexWelding::* LOCATE_CALLBACK)(const Vertex &v, uint32_t bucket, bool &isAllDataTheSame)
Definition: NvBlastExtRTGeometry.h:22
Nv::Blast::BooleanToolV2::mAccelB
SpatialAccelerator * mAccelB
Definition: NvBlastExtRTGeometry.h:106
NvBlastExtAuthoringInternalCommon.h
Nv::Blast::TriangulatorV2::LinkedListElement::nextPoint
uint32_t nextPoint
Definition: NvBlastExtRTGeometry.h:192
Nv::Blast::BooleanToolV2
Definition: NvBlastExtRTGeometry.h:62
Nv::Blast::TriangulatorV2::weldedCount
uint32_t weldedCount
Definition: NvBlastExtRTGeometry.h:197
Nv::Blast::BooleanToolV2::Mode::Difference
static Mode Difference()
Definition: NvBlastExtRTGeometry.h:89
Nv::Blast::TriangulatorV2::triangleCount
uint32_t triangleCount
Definition: NvBlastExtRTGeometry.h:199
Nv::Blast::BooleanToolV2::Mode
Definition: NvBlastExtRTGeometry.h:66
z
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition: btVector3.h:279
Nv::Blast::BooleanToolV2::mAccelA
SpatialAccelerator * mAccelA
Definition: NvBlastExtRTGeometry.h:105
Nv::Blast::VertexWelding::VertexWelding
VertexWelding(uint32_t maxVertexCount, uint32_t maxBucketCount, float gridCellSize, float weldEpsilon, float auxEpsilon, LOCATE_CALLBACK clb)
Nv::Blast::Edge
Definition: NvBlastExtAuthoringTypes.h:57
Nv::Blast::BooleanToolV2::Mode::Mode
Mode(int32_t a, int32_t b, int32_t c)
Definition: NvBlastExtRTGeometry.h:70
Nv::Blast::Vertex
Definition: NvBlastExtAuthoringTypes.h:67
Nv::Blast::MeshGenerator
Definition: NvBlastExtRT.h:126
Nv::Blast::Fracturer
Definition: NvBlastExtRT.h:120
Nv
Definition: NvBlastArray.h:37
NvBlastExtRT.h
Nv::Blast::VertexWelding::LocateVertexInBucketOnlyPosition
int32_t LocateVertexInBucketOnlyPosition(const Vertex &v, uint32_t bucket, bool &isAllDataTheSame)
Nv::Blast::VertexWelding::reset
void reset()