diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index 07e9c7da66..246f9d85b6 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -517,8 +517,6 @@ namespace DetourNavigator " playerTile=(" << playerTile << ")" << " changedTileDistance=" << getDistance(changedTile, playerTile); - const auto params = *navMeshCacheItem->lockConst()->getImpl().getParams(); - if (!recastMesh) { Log(Debug::Debug) << "Ignore add tile: recastMesh is null"; @@ -542,6 +540,8 @@ namespace DetourNavigator return navMeshCacheItem->lock()->removeTile(changedTile); } + const dtNavMeshParams params = *navMeshCacheItem->lockConst()->getImpl().getParams(); + if (!shouldAddTile(changedTile, playerTile, std::min(settings.mMaxTilesNumber, params.maxTiles))) { Log(Debug::Debug) << "Ignore add tile: too far from player";