diff --git a/src/naveditor/Editor_TileMesh.cpp b/src/naveditor/Editor_TileMesh.cpp index e7ea4933..e5ba8ac0 100644 --- a/src/naveditor/Editor_TileMesh.cpp +++ b/src/naveditor/Editor_TileMesh.cpp @@ -759,7 +759,7 @@ void Editor_TileMesh::buildAllTiles() } } - if (!dtBuildStaticPathingData(m_navMesh)) + if (!dtCreateStaticPathingData(m_navMesh)) { m_ctx->log(RC_LOG_ERROR, "buildNavigation: Failed to build static pathing data."); } diff --git a/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h b/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h index 4f893143..7287bacf 100644 --- a/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h +++ b/src/thirdparty/recast/Detour/Include/DetourNavMeshBuilder.h @@ -168,7 +168,11 @@ private: rdIntArray parent; }; -bool dtBuildStaticPathingData(dtNavMesh* mesh); +/// Builds navigation mesh static pathing data from the provided navmesh. +/// @ingroup detour +/// @param[in] mesh Tile creation data. +/// @return True if the static pathing data was successfully created. +bool dtCreateStaticPathingData(dtNavMesh* mesh); /// Builds navigation mesh tile data from the provided tile creation data. /// @ingroup detour diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp index fdea255e..434945d5 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshBuilder.cpp @@ -269,7 +269,7 @@ static unsigned char classifyOffMeshPoint(const float* pt, const float* bmin, co return 0xff; } -static void setReachable(int* const tableData, const int numPolyGroups, +static void setPolyGroupsReachability(int* const tableData, const int numPolyGroups, const int polyGroup1, const int polyGroup2, const bool isReachable) { const int index = polyGroup1*((numPolyGroups+31)/32)+(polyGroup2/32); @@ -281,7 +281,7 @@ static void setReachable(int* const tableData, const int numPolyGroups, tableData[index] &= ~value; } -bool dtBuildStaticPathingData(dtNavMesh* mesh) +bool dtCreateStaticPathingData(dtNavMesh* mesh) { rdAssert(mesh); @@ -303,7 +303,7 @@ bool dtBuildStaticPathingData(dtNavMesh* mesh) } } - // First pass. + // First pass to group linked and unlinked poly islands. std::set nlabels; for (int i = 0; i < mesh->getMaxTiles(); ++i) { @@ -347,7 +347,7 @@ bool dtBuildStaticPathingData(dtNavMesh* mesh) } } - // Second pass. + // Second pass to ensure all poly's have their root disjoint set ID. for (int i = 0; i < mesh->getMaxTiles(); ++i) { dtMeshTile* tile = mesh->getTile(i); @@ -418,8 +418,9 @@ bool dtBuildStaticPathingData(dtNavMesh* mesh) { for (int k = 0; k < numPolyGroups; k++) { + // Only reachable if its the same polygroup or if they are linked! const bool isReachable = j == k || data.find(j) == data.find(k); - setReachable(reachabilityTable, numPolyGroups, j, k, isReachable); + setPolyGroupsReachability(reachabilityTable, numPolyGroups, j, k, isReachable); } } }