From b4e7bb7886418d55934e2d826898fd29ec4fc1cf Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 3 Nov 2024 15:16:10 +0100 Subject: [PATCH] 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. --- src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp index 46744097..78662d59 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMesh.cpp @@ -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) {