aboutsummaryrefslogtreecommitdiff
path: root/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h
diff options
context:
space:
mode:
authorAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
committerAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
commit236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch)
treee486f2fa39dba203563895541e92c60ed3e25759 /sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h
parentAdded screens to welcome page (diff)
downloadblast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz
blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h')
-rw-r--r--sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h200
1 files changed, 38 insertions, 162 deletions
diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h b/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h
index 83942f4..c5cb5b1 100644
--- a/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h
+++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef NVBLASTEXTAUTHORINGTRIANGULATOR_H
#define NVBLASTEXTAUTHORINGTRIANGULATOR_H
@@ -22,95 +40,19 @@ namespace Nv
{
namespace Blast
{
-class SimplexNoise;
-
-/**
- Vertex comparator for vertex welding.
-*/
-struct VrtComp
-{
- bool operator()(const Vertex& a, const Vertex& b) const;
-};
-
-/**
- Vertex comparator for vertex welding (not accounts normal and uv parameters of vertice).
-*/
-struct VrtPositionComparator
-{
- bool operator()(const physx::PxVec3& a, const physx::PxVec3& b) const;
-};
-
-/**
- Structure used on tesselation stage. Maps edge to two neighboor triangles
-*/
-struct EdgeToTriangles
-{
- int32_t tr[2];
- int32_t c;
- EdgeToTriangles()
- {
- c = 0;
- }
- /**
- Add triangle to edge. Should not be called more than twice for one edge!!!!.
- */
- void add(int32_t t)
- {
- tr[c] = t;
- ++c;
- }
- /**
- Replaces mapping from one triangle to another.
- */
- void replace(int32_t from, int32_t to)
- {
- if (tr[0] == from)
- {
- tr[0] = to;
- }
- else
- {
- if (c == 2 && tr[1] == from)
- {
- tr[1] = to;
- }
- }
- }
- /**
- Get triangle which is mapped by this edge and which index is different than provided.
- */
- int32_t getNot(int32_t id)
- {
- if (tr[0] != id)
- {
- return tr[0];
- }
- if (c == 2 && tr[1] != id)
- {
- return tr[1];
- }
- return -1;
- }
-
-};
/**
Tool for doing all post processing steps of authoring.
*/
-class ChunkPostProcessor
+class Triangulator
{
public:
/**
- Edge flags
- */
- enum EdgeFlag{ INTERNAL_EDGE, EXTERNAL_BORDER_EDGE, INTERNAL_BORDER_EDGE, EXTERNAL_EDGE, NONE };
-
- /**
Triangulates provided mesh and saves result internally. Uses Ear-clipping algorithm.
\param[in] mesh Mesh for triangulation
*/
- void triangulate(Mesh* mesh);
+ void triangulate(const Mesh* mesh);
/**
\return Return array of triangles of base mesh.
@@ -127,8 +69,6 @@ public:
{
return mBaseMeshTriangles;
}
-
-
/**
\return Return mapping from vertices of input Mesh to internal vertices buffer. Used for island detection.
*/
@@ -143,7 +83,6 @@ public:
{
return mPositionMappedVrt;
};
-
/**
\return Return internal vertex buffer size. Vertices internally are welded with some threshold.
*/
@@ -151,44 +90,15 @@ public:
{
return static_cast<uint32_t>(mVertices.size());
}
- /**
- Tesselate internal surface.
- \param[in] maxLen - maximal length of edge on internal surface.
- */
- void tesselateInternalSurface(float maxLen);
-
- /**
- Apply noise to internal surface. Must be called only after tesselation!!!
- \param[in] noise - noise generator
- \param[in] falloff - damping of noise around of external surface
- \param[in] relaxIterations - number of smoothing iterations before applying noise
- \param[in] relaxFactor - amount of smooting before applying noise.
- */
- void applyNoise(SimplexNoise& noise, float falloff, int32_t relaxIterations, float relaxFactor);
-
- /**
- \return Return array of noised mesh triangles.
- */
- std::vector<Triangle>& getNoisyMesh()
- {
- return mTesselatedMeshResultTriangles;
- };
/**
- Removes all information about mesh triangulation, tesselation, etc.
+ Removes all information about mesh triangulation.
*/
void reset();
private:
-
-
- void collapseEdge(int32_t id);
- void divideEdge(int32_t id);
- void updateVertEdgeInfo();
- void updateEdgeTriangleInfo();
-
- int32_t addVerticeIfNotExist(Vertex& p);
+ int32_t addVerticeIfNotExist(const Vertex& p);
void addEdgeIfValid(EdgeWithParent& ed);
/* Data used before triangulation to build polygon loops*/
@@ -198,60 +108,26 @@ private:
std::map<Vertex, int32_t, VrtComp> mVertMap;
std::map<EdgeWithParent, int32_t, EdgeComparator> mEdgeMap;
std::vector<uint32_t> mBaseMapping;
-
+ std::vector<int32_t> mPositionMappedVrt;
+ /* ------------------------------------------------------------ */
/**
Unite all almost similar vertices, update edges according to this changes
*/
- void prepare(Mesh* mesh);
-
- /* ------------------------------------------------------------ */
-
- /* Triangulation and tesselation stage data */
- bool isTesselated;
-
- std::map<Edge, int32_t> mTrMeshEdgeMap;
- std::vector<Edge> mTrMeshEdges;
- std::vector<EdgeToTriangles> mTrMeshEdToTr;
- std::vector<int32_t> mVertexValence;
- std::vector<std::vector<int32_t> > mVertexToTriangleMap;
-
- std::vector<bool> mRestrictionFlag;
- std::vector<EdgeFlag> mEdgeFlag;
-
- std::vector<float> mVerticesDistances;
- std::vector<physx::PxVec3> mVerticesNormalsSmoothed;
- std::vector<int32_t> mPositionMappedVrt;
- std::vector<std::vector<int32_t> > mGeometryGraph;
-
-
- int32_t addEdgeTr(const Edge& ed);
- int32_t findEdge(const Edge& e);
-
- void prebuildEdgeFlagArray();
- void computePositionedMapping();
-
- void computeFalloffAndNormals();
-
+ void prepare(const Mesh* mesh);
+
void triangulatePolygonWithEarClipping(std::vector<uint32_t>& inputPolygon, Vertex* vert, ProjectionDirections dir);
- void buildPolygonAndTriangulate(std::vector<Edge>& edges, Vertex* vertices, int32_t userData);
+ void buildPolygonAndTriangulate(std::vector<Edge>& edges, Vertex* vertices, int32_t userData, int32_t materialId, int32_t smoothingGroup);
+ void computePositionedMapping();
- void relax(int32_t iterations, float factor, std::vector<Vertex>& vertices);
- void recalcNoiseDirs();
-
- std::vector<TriangleIndexed> mBaseMeshTriangles;
- std::vector<TriangleIndexed> mTesselatedMeshTriangles;
-
+ std::vector<TriangleIndexed> mBaseMeshTriangles;
/**
Final triangles
*/
- void prebuildTesselatedTriangles();
-
std::vector<Triangle> mBaseMeshResultTriangles;
- std::vector<Triangle> mTesselatedMeshResultTriangles;
};
} // namespace Blast