1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:29:55 +00:00

Mark TileCachedRecastMeshManager member functions as const where possible

This commit is contained in:
elsid 2021-08-08 16:58:47 +02:00
parent 3c6f145753
commit 8ac8d56e8c
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
4 changed files with 12 additions and 12 deletions

View file

@ -117,7 +117,7 @@ namespace DetourNavigator
return result;
}
std::shared_ptr<RecastMesh> RecastMeshManager::getMesh()
std::shared_ptr<RecastMesh> RecastMeshManager::getMesh() const
{
TileBounds tileBounds = mTileBounds;
tileBounds.mMin /= mSettings.mRecastScaleFactor;

View file

@ -52,7 +52,7 @@ namespace DetourNavigator
std::optional<Cell> removeHeightfield(const osg::Vec2i& cellPosition);
std::shared_ptr<RecastMesh> getMesh();
std::shared_ptr<RecastMesh> getMesh() const;
bool isEmpty() const;

View file

@ -190,11 +190,11 @@ namespace DetourNavigator
return result;
}
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getMesh(const TilePosition& tilePosition)
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getMesh(const TilePosition& tilePosition) const
{
const auto manager = [&] () -> std::shared_ptr<CachedRecastMeshManager>
{
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;

View file

@ -86,20 +86,20 @@ namespace DetourNavigator
std::optional<Cell> removeHeightfield(const osg::Vec2i& cellPosition);
std::shared_ptr<RecastMesh> getMesh(const TilePosition& tilePosition);
std::shared_ptr<RecastMesh> getMesh(const TilePosition& tilePosition) const;
bool hasTile(const TilePosition& tilePosition);
bool hasTile(const TilePosition& tilePosition) const;
template <class Function>
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<TilePosition, std::shared_ptr<CachedRecastMeshManager>>;