Recast: never attempt link to the same polygon

Big optimization as you cannot link to the same polygon, you also cannot link to the same triangle. This drops polyCount number of iterations on polygons per tile.
This commit is contained in:
Kawe Mazidjatari 2024-11-03 15:16:10 +01:00
parent 7c3509fd34
commit b4e7bb7886

View File

@ -952,6 +952,9 @@ dtStatus dtNavMesh::connectTraverseLinks(const dtTileRef tileRef, const dtTraver
if (landPoly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
continue;
if (landPoly == basePoly)
continue;
// If both polygons are sharing an edge, we should not establish the link as
// it will cause pathfinding to fail in this area when both polygons have
// their first link set to another; the path will never exit these polygons.
@ -972,6 +975,8 @@ dtStatus dtNavMesh::connectTraverseLinks(const dtTileRef tileRef, const dtTraver
for (int q = 0; (q < landDetail->triCount) && !moveToNextTile; ++q)
{
const unsigned char* landTri = &landTile->detailTris[(landDetail->triBase+q)*4];
rdAssert(landTri != baseTri);
const float* landTriVerts[3];
for (int r = 0; r < 3; ++r)
{