Recast: fix generation of concave polygons

These changes seem to yield better results for the larger maps. The improvements are minimal however. This change is probably more noticable on tile cache.
This commit is contained in:
Kawe Mazidjatari 2024-10-25 01:12:51 +02:00
parent 6451405fba
commit ed9cd80034
2 changed files with 18 additions and 22 deletions

View File

@ -1284,18 +1284,16 @@ static int triangulate(int n, const unsigned char* verts, unsigned short* indice
for (int k = i1; k < n; k++)
indices[k] = indices[k+1];
if (i1 >= n) i1 = 0;
i = REV_STEP_DIR(i1,n);
// Update diagonal flags.
if (diagonal(REV_STEP_DIR(i, n), i1, n, verts, indices))
indices[i] |= 0x8000;
else
indices[i] &= 0x7fff;
if (diagonal(i, STEP_DIR(i1, n), n, verts, indices))
indices[i1] |= 0x8000;
else
indices[i1] &= 0x7fff;
for (int k = 0; k < n; k++) // See https://github.com/recastnavigation/recastnavigation/pull/734
{
const int k1 = STEP_DIR(k, n);
const int k2 = STEP_DIR(k1, n);
if (diagonal(k, k2, n, verts, indices))
indices[k1] |= 0x8000;
else
indices[k1] &= 0x7fff;
}
}
// Append the remaining triangle.

View File

@ -457,18 +457,16 @@ static int triangulate(int n, const int* verts, int* indices, int* tris)
for (int k = i1; k < n; k++)
indices[k] = indices[k+1];
if (i1 >= n) i1 = 0;
i = REV_STEP_DIR(i1,n);
// Update diagonal flags.
if (diagonal(REV_STEP_DIR(i, n), i1, n, verts, indices))
indices[i] |= 0x80000000;
else
indices[i] &= 0x0fffffff;
if (diagonal(i, STEP_DIR(i1, n), n, verts, indices))
indices[i1] |= 0x80000000;
else
indices[i1] &= 0x0fffffff;
for (int k = 0; k < n; k++) // See https://github.com/recastnavigation/recastnavigation/pull/734
{
const int k1 = STEP_DIR(k, n);
const int k2 = STEP_DIR(k1, n);
if (diagonal(k, k2, n, verts, indices))
indices[k1] |= 0x80000000;
else
indices[k1] &= 0x0fffffff;
}
}
// Append the remaining triangle.