From 16bea738b82b34217acce33eff7a2d1d34eef2be Mon Sep 17 00:00:00 2001 From: tfabretti Date: Mon, 2 May 2016 20:55:42 +0200 Subject: [PATCH] Fixed a links issue due to offmesh connections When creating the tile's links, offmesh connections inside the tile were added twice, leading to the array of links being full and not being able to store the links computed after (portals between tiles). --- Detour/Source/DetourNavMesh.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Detour/Source/DetourNavMesh.cpp b/Detour/Source/DetourNavMesh.cpp index 77d1ed4..f70fa04 100644 --- a/Detour/Source/DetourNavMesh.cpp +++ b/Detour/Source/DetourNavMesh.cpp @@ -943,7 +943,10 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, tile->flags = flags; connectIntLinks(tile); + + // Base off-mesh connections to their starting polygons and connect connections inside the tile. baseOffMeshLinks(tile); + connectExtOffMeshLinks(tile, tile, -1); // Create connections with neighbour tiles. static const int MAX_NEIS = 32; @@ -954,11 +957,11 @@ dtStatus dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, nneis = getTilesAt(header->x, header->y, neis, MAX_NEIS); for (int j = 0; j < nneis; ++j) { - if (neis[j] != tile) - { - connectExtLinks(tile, neis[j], -1); - connectExtLinks(neis[j], tile, -1); - } + if (neis[j] == tile) + continue; + + connectExtLinks(tile, neis[j], -1); + connectExtLinks(neis[j], tile, -1); connectExtOffMeshLinks(tile, neis[j], -1); connectExtOffMeshLinks(neis[j], tile, -1); }