aboutsummaryrefslogtreecommitdiff
path: root/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2018-01-22 14:04:16 -0800
committerBryan Galdrikian <[email protected]>2018-01-22 14:04:16 -0800
commit1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d (patch)
tree5f8ca75a6b92c60fb5cf3b14282fc4cc1c127eb2 /sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp
parentUpdating readme.md to show updated UE4 Blast integration branches (diff)
downloadblast-1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d.tar.xz
blast-1dc1a87fba520bb45c1ce8165e8ea2c83c0a308d.zip
Changes for 1.1.2 release candidate
See README.md, docs/release_notes.txt
Diffstat (limited to 'sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp')
-rw-r--r--sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp b/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp
index cc2442c..e7cbb06 100644
--- a/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp
+++ b/sdk/extensions/authoring/source/NvBlastExtAuthoringTriangulator.cpp
@@ -47,20 +47,21 @@
using physx::PxVec3;
using physx::PxVec2;
-#define TWO_VERTICES_THRESHOLD 1e-7
-
namespace Nv
{
namespace Blast
{
-
+NV_FORCE_INLINE bool compareTwoFloats(float a, float b)
+{
+ return std::abs(b - a) <= FLT_EPSILON * std::abs(b + a);
+}
NV_FORCE_INLINE bool compareTwoVertices(const PxVec3& a, const PxVec3& b)
{
- return std::abs(b.x - a.x) < TWO_VERTICES_THRESHOLD && std::abs(b.y - a.y) < TWO_VERTICES_THRESHOLD && std::abs(b.z - a.z) < TWO_VERTICES_THRESHOLD;
+ return compareTwoFloats(a.x, b.x) && compareTwoFloats(a.y, b.y) && compareTwoFloats(a.z, b.z);
}
NV_FORCE_INLINE bool compareTwoVertices(const PxVec2& a, const PxVec2& b)
{
- return std::abs(b.x - a.x) < TWO_VERTICES_THRESHOLD && std::abs(b.y - a.y) < TWO_VERTICES_THRESHOLD;
+ return compareTwoFloats(a.x, b.x) && compareTwoFloats(a.y, b.y);
}
NV_FORCE_INLINE float getRotation(const PxVec2& a, const PxVec2& b)
@@ -68,7 +69,7 @@ NV_FORCE_INLINE float getRotation(const PxVec2& a, const PxVec2& b)
return a.x * b.y - a.y * b.x;
}
-inline bool pointInside(PxVec2 a, PxVec2 b, PxVec2 c, PxVec2 pnt)
+NV_FORCE_INLINE bool pointInside(PxVec2 a, PxVec2 b, PxVec2 c, PxVec2 pnt)
{
if (compareTwoVertices(a, pnt) || compareTwoVertices(b, pnt) || compareTwoVertices(c, pnt))
{
@@ -471,7 +472,10 @@ NV_FORCE_INLINE void Triangulator::addEdgeIfValid(EdgeWithParent& ed)
mBaseMeshEdges[it->second].s = ed.s;
mBaseMeshEdges[it->second].e = ed.e;
}
- mBaseMeshEdges[it->second].s = NOT_VALID_VERTEX;
+ else
+ {
+ mBaseMeshEdges[it->second].s = NOT_VALID_VERTEX;
+ }
}
}
@@ -504,7 +508,7 @@ void Triangulator::prepare(const Mesh* mesh)
temp.push_back(mBaseMeshEdges[i]);
}
}
-
+ mBaseMeshEdges = temp;
}
void Triangulator::reset()
@@ -560,6 +564,7 @@ void Triangulator::triangulate(const Mesh* mesh)
mBaseMeshResultTriangles.back().smoothingGroup = mBaseMeshTriangles[i].smoothingGroup;
}
+ mBaseMeshUVFittedTriangles = mBaseMeshResultTriangles; // Uvs will be fitted later, in FractureTool.
computePositionedMapping();
}