diff --git a/components/detournavigator/recastmeshmanager.cpp b/components/detournavigator/recastmeshmanager.cpp index e4e5b76449..2eeb90a9b5 100644 --- a/components/detournavigator/recastmeshmanager.cpp +++ b/components/detournavigator/recastmeshmanager.cpp @@ -117,7 +117,7 @@ namespace DetourNavigator return result; } - std::shared_ptr RecastMeshManager::getMesh() + std::shared_ptr RecastMeshManager::getMesh() const { TileBounds tileBounds = mTileBounds; tileBounds.mMin /= mSettings.mRecastScaleFactor; diff --git a/components/detournavigator/recastmeshmanager.hpp b/components/detournavigator/recastmeshmanager.hpp index 1cd35ca467..e1c1567cb3 100644 --- a/components/detournavigator/recastmeshmanager.hpp +++ b/components/detournavigator/recastmeshmanager.hpp @@ -52,7 +52,7 @@ namespace DetourNavigator std::optional removeHeightfield(const osg::Vec2i& cellPosition); - std::shared_ptr getMesh(); + std::shared_ptr getMesh() const; bool isEmpty() const; diff --git a/components/detournavigator/tilecachedrecastmeshmanager.cpp b/components/detournavigator/tilecachedrecastmeshmanager.cpp index 2b8c85b8a3..8033ca89ac 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.cpp @@ -190,11 +190,11 @@ namespace DetourNavigator return result; } - std::shared_ptr TileCachedRecastMeshManager::getMesh(const TilePosition& tilePosition) + std::shared_ptr TileCachedRecastMeshManager::getMesh(const TilePosition& tilePosition) const { const auto manager = [&] () -> std::shared_ptr { - const auto tiles = mTiles.lock(); + const auto tiles = mTiles.lockConst(); const auto it = tiles->find(tilePosition); if (it == tiles->end()) return nullptr; @@ -205,7 +205,7 @@ namespace DetourNavigator return manager->getMesh(); } - bool TileCachedRecastMeshManager::hasTile(const TilePosition& tilePosition) + bool TileCachedRecastMeshManager::hasTile(const TilePosition& tilePosition) const { return mTiles.lockConst()->count(tilePosition); } @@ -215,9 +215,9 @@ namespace DetourNavigator return mRevision; } - void TileCachedRecastMeshManager::reportNavMeshChange(const TilePosition& tilePosition, Version recastMeshVersion, Version navMeshVersion) + void TileCachedRecastMeshManager::reportNavMeshChange(const TilePosition& tilePosition, Version recastMeshVersion, Version navMeshVersion) const { - const auto tiles = mTiles.lock(); + const auto tiles = mTiles.lockConst(); const auto it = tiles->find(tilePosition); if (it == tiles->end()) return; diff --git a/components/detournavigator/tilecachedrecastmeshmanager.hpp b/components/detournavigator/tilecachedrecastmeshmanager.hpp index f8cb5a8b0e..f10260a4dd 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.hpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.hpp @@ -86,20 +86,20 @@ namespace DetourNavigator std::optional removeHeightfield(const osg::Vec2i& cellPosition); - std::shared_ptr getMesh(const TilePosition& tilePosition); + std::shared_ptr getMesh(const TilePosition& tilePosition) const; - bool hasTile(const TilePosition& tilePosition); + bool hasTile(const TilePosition& tilePosition) const; template - void forEachTile(Function&& function) + void forEachTile(Function&& function) const { - for (auto& [tilePosition, recastMeshManager] : *mTiles.lock()) + for (auto& [tilePosition, recastMeshManager] : *mTiles.lockConst()) function(tilePosition, *recastMeshManager); } std::size_t getRevision() const; - void reportNavMeshChange(const TilePosition& tilePosition, Version recastMeshVersion, Version navMeshVersion); + void reportNavMeshChange(const TilePosition& tilePosition, Version recastMeshVersion, Version navMeshVersion) const; private: using TilesMap = std::map>;