summaryrefslogtreecommitdiff
path: root/thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp')
-rw-r--r--thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp b/thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp
index f953132f74..9a423cab8a 100644
--- a/thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp
+++ b/thirdparty/recastnavigation/Recast/Source/RecastMeshDetail.cpp
@@ -557,15 +557,16 @@ static float polyMinExtent(const float* verts, const int nverts)
inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }
inline int next(int i, int n) { return i+1 < n ? i+1 : 0; }
-static void triangulateHull(const int /*nverts*/, const float* verts, const int nhull, const int* hull, rcIntArray& tris)
+static void triangulateHull(const int /*nverts*/, const float* verts, const int nhull, const int* hull, const int nin, rcIntArray& tris)
{
int start = 0, left = 1, right = nhull-1;
// Start from an ear with shortest perimeter.
// This tends to favor well formed triangles as starting point.
- float dmin = 0;
+ float dmin = FLT_MAX;
for (int i = 0; i < nhull; i++)
{
+ if (hull[i] >= nin) continue; // Ears are triangles with original vertices as middle vertex while others are actually line segments on edges
int pi = prev(i, nhull);
int ni = next(i, nhull);
const float* pv = &verts[hull[pi]*3];
@@ -770,7 +771,7 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
// If the polygon minimum extent is small (sliver or small triangle), do not try to add internal points.
if (minExtent < sampleDist*2)
{
- triangulateHull(nverts, verts, nhull, hull, tris);
+ triangulateHull(nverts, verts, nhull, hull, nin, tris);
return true;
}
@@ -778,7 +779,7 @@ static bool buildPolyDetail(rcContext* ctx, const float* in, const int nin,
// We're using the triangulateHull instead of delaunayHull as it tends to
// create a bit better triangulation for long thin triangles when there
// are no internal points.
- triangulateHull(nverts, verts, nhull, hull, tris);
+ triangulateHull(nverts, verts, nhull, hull, nin, tris);
if (tris.size() == 0)
{
@@ -1140,7 +1141,8 @@ static void getHeightData(rcContext* ctx, const rcCompactHeightfield& chf,
static unsigned char getEdgeFlags(const float* va, const float* vb,
const float* vpoly, const int npoly)
{
- // Return true if edge (va,vb) is part of the polygon.
+ // The flag returned by this function matches dtDetailTriEdgeFlags in Detour.
+ // Figure out if edge (va,vb) is part of the polygon boundary.
static const float thrSqr = rcSqr(0.001f);
for (int i = 0, j = npoly-1; i < npoly; j=i++)
{