diff --git a/apps/benchmarks/detournavigator/navmeshtilescache.cpp b/apps/benchmarks/detournavigator/navmeshtilescache.cpp index c6e6ecbdbc..70ffdde3c9 100644 --- a/apps/benchmarks/detournavigator/navmeshtilescache.cpp +++ b/apps/benchmarks/detournavigator/navmeshtilescache.cpp @@ -83,7 +83,7 @@ namespace std::uniform_real_distribution distribution(0.0, 1.0); std::generate_n(out, count, [&] { const osg::Vec3f shift(distribution(random), distribution(random), distribution(random)); - return Water {1, shift}; + return Cell {1, shift}; }); } @@ -108,7 +108,7 @@ namespace const std::size_t generation = std::uniform_int_distribution(0, 100)(random); const std::size_t revision = std::uniform_int_distribution(0, 10000)(random); Mesh mesh = generateMesh(triangles, random); - std::vector water; + std::vector water; generateWater(std::back_inserter(water), 2, random); RecastMesh recastMesh(generation, revision, std::move(mesh), std::move(water)); return Key {agentHalfExtents, tilePosition, std::move(recastMesh)}; diff --git a/apps/openmw_test_suite/detournavigator/navmeshtilescache.cpp b/apps/openmw_test_suite/detournavigator/navmeshtilescache.cpp index c9c2a6528b..8c66f1a3ef 100644 --- a/apps/openmw_test_suite/detournavigator/navmeshtilescache.cpp +++ b/apps/openmw_test_suite/detournavigator/navmeshtilescache.cpp @@ -143,12 +143,12 @@ namespace const std::size_t mGeneration = 0; const std::size_t mRevision = 0; const Mesh mMesh {makeMesh()}; - const std::vector mWater {}; + const std::vector mWater {}; const RecastMesh mRecastMesh {mGeneration, mRevision, mMesh, mWater}; std::unique_ptr mPreparedNavMeshData {makePeparedNavMeshData(3)}; const std::size_t mRecastMeshSize = sizeof(mRecastMesh) + getSize(mRecastMesh); - const std::size_t mRecastMeshWithWaterSize = mRecastMeshSize + sizeof(Water); + const std::size_t mRecastMeshWithWaterSize = mRecastMeshSize + sizeof(Cell); const std::size_t mPreparedNavMeshDataSize = sizeof(*mPreparedNavMeshData) + getSize(*mPreparedNavMeshData); }; @@ -231,7 +231,7 @@ namespace { const std::size_t maxSize = 1; NavMeshTilesCache cache(maxSize); - const std::vector water {1, Water {1, osg::Vec3f()}}; + const std::vector water {1, Cell {1, osg::Vec3f()}}; const RecastMesh unexistentRecastMesh {mGeneration, mRevision, mMesh, water}; cache.set(mAgentHalfExtents, mTilePosition, mRecastMesh, std::move(mPreparedNavMeshData)); @@ -243,7 +243,7 @@ namespace const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize; NavMeshTilesCache cache(maxSize); - const std::vector water {1, Water {1, osg::Vec3f()}}; + const std::vector water {1, Cell {1, osg::Vec3f()}}; const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water}; auto anotherPreparedNavMeshData = makePeparedNavMeshData(3); const auto copy = clone(*anotherPreparedNavMeshData); @@ -261,7 +261,7 @@ namespace const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize; NavMeshTilesCache cache(maxSize); - const std::vector water {1, Water {1, osg::Vec3f()}}; + const std::vector water {1, Cell {1, osg::Vec3f()}}; const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water}; auto anotherPreparedNavMeshData = makePeparedNavMeshData(3); @@ -277,11 +277,11 @@ namespace NavMeshTilesCache cache(maxSize); const auto copy = clone(*mPreparedNavMeshData); - const std::vector leastRecentlySetWater {1, Water {1, osg::Vec3f()}}; + const std::vector leastRecentlySetWater {1, Cell {1, osg::Vec3f()}}; const RecastMesh leastRecentlySetRecastMesh {mGeneration, mRevision, mMesh, leastRecentlySetWater}; auto leastRecentlySetData = makePeparedNavMeshData(3); - const std::vector mostRecentlySetWater {1, Water {2, osg::Vec3f()}}; + const std::vector mostRecentlySetWater {1, Cell {2, osg::Vec3f()}}; const RecastMesh mostRecentlySetRecastMesh {mGeneration, mRevision, mMesh, mostRecentlySetWater}; auto mostRecentlySetData = makePeparedNavMeshData(3); @@ -303,12 +303,12 @@ namespace const std::size_t maxSize = 2 * (mRecastMeshWithWaterSize + mPreparedNavMeshDataSize); NavMeshTilesCache cache(maxSize); - const std::vector leastRecentlyUsedWater {1, Water {1, osg::Vec3f()}}; + const std::vector leastRecentlyUsedWater {1, Cell {1, osg::Vec3f()}}; const RecastMesh leastRecentlyUsedRecastMesh {mGeneration, mRevision, mMesh, leastRecentlyUsedWater}; auto leastRecentlyUsedData = makePeparedNavMeshData(3); const auto leastRecentlyUsedCopy = clone(*leastRecentlyUsedData); - const std::vector mostRecentlyUsedWater {1, Water {2, osg::Vec3f()}}; + const std::vector mostRecentlyUsedWater {1, Cell {2, osg::Vec3f()}}; const RecastMesh mostRecentlyUsedRecastMesh {mGeneration, mRevision, mMesh, mostRecentlyUsedWater}; auto mostRecentlyUsedData = makePeparedNavMeshData(3); const auto mostRecentlyUsedCopy = clone(*mostRecentlyUsedData); @@ -342,7 +342,7 @@ namespace const std::size_t maxSize = 2 * (mRecastMeshWithWaterSize + mPreparedNavMeshDataSize); NavMeshTilesCache cache(maxSize); - const std::vector water {1, Water {1, osg::Vec3f()}}; + const std::vector water {1, Cell {1, osg::Vec3f()}}; const RecastMesh tooLargeRecastMesh {mGeneration, mRevision, mMesh, water}; auto tooLargeData = makePeparedNavMeshData(10); @@ -356,11 +356,11 @@ namespace const std::size_t maxSize = 2 * (mRecastMeshWithWaterSize + mPreparedNavMeshDataSize); NavMeshTilesCache cache(maxSize); - const std::vector anotherWater {1, Water {1, osg::Vec3f()}}; + const std::vector anotherWater {1, Cell {1, osg::Vec3f()}}; const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, anotherWater}; auto anotherData = makePeparedNavMeshData(3); - const std::vector tooLargeWater {1, Water {2, osg::Vec3f()}}; + const std::vector tooLargeWater {1, Cell {2, osg::Vec3f()}}; const RecastMesh tooLargeRecastMesh {mGeneration, mRevision, mMesh, tooLargeWater}; auto tooLargeData = makePeparedNavMeshData(10); @@ -380,7 +380,7 @@ namespace const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize; NavMeshTilesCache cache(maxSize); - const std::vector water {1, Water {1, osg::Vec3f()}}; + const std::vector water {1, Cell {1, osg::Vec3f()}}; const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water}; auto anotherData = makePeparedNavMeshData(3); @@ -399,7 +399,7 @@ namespace const std::size_t maxSize = mRecastMeshWithWaterSize + mPreparedNavMeshDataSize; NavMeshTilesCache cache(maxSize); - const std::vector water {1, Water {1, osg::Vec3f()}}; + const std::vector water {1, Cell {1, osg::Vec3f()}}; const RecastMesh anotherRecastMesh {mGeneration, mRevision, mMesh, water}; auto anotherData = makePeparedNavMeshData(3); diff --git a/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp b/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp index ac565e36c0..b6478f9ea6 100644 --- a/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp +++ b/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp @@ -19,9 +19,9 @@ namespace DetourNavigator { - static inline bool operator ==(const Water& lhs, const Water& rhs) + static inline bool operator ==(const Cell& lhs, const Cell& rhs) { - return lhs.mCellSize == rhs.mCellSize && lhs.mShift == rhs.mShift; + return lhs.mSize == rhs.mSize && lhs.mShift == rhs.mShift; } } @@ -404,8 +404,8 @@ namespace RecastMeshBuilder builder(mBounds); builder.addWater(1000, osg::Vec3f(100, 200, 300)); const auto recastMesh = std::move(builder).create(mGeneration, mRevision); - EXPECT_EQ(recastMesh->getWater(), std::vector({ - Water {1000, osg::Vec3f(100, 200, 300)} + EXPECT_EQ(recastMesh->getWater(), std::vector({ + Cell {1000, osg::Vec3f(100, 200, 300)} })); } diff --git a/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp b/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp index 59938ad2be..cb1f04b8b0 100644 --- a/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp @@ -295,7 +295,7 @@ namespace ASSERT_TRUE(manager.addWater(cellPosition, cellSize, osg::Vec3f())); const auto result = manager.removeWater(cellPosition); ASSERT_TRUE(result.has_value()); - EXPECT_EQ(result->mCellSize, cellSize); + EXPECT_EQ(result->mSize, cellSize); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_remove_empty_tiles) diff --git a/components/detournavigator/cachedrecastmeshmanager.cpp b/components/detournavigator/cachedrecastmeshmanager.cpp index 1242b32318..cfbb77f238 100644 --- a/components/detournavigator/cachedrecastmeshmanager.cpp +++ b/components/detournavigator/cachedrecastmeshmanager.cpp @@ -42,7 +42,7 @@ namespace DetourNavigator return true; } - std::optional CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) + std::optional CachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) { const auto water = mImpl.removeWater(cellPosition); if (water) diff --git a/components/detournavigator/cachedrecastmeshmanager.hpp b/components/detournavigator/cachedrecastmeshmanager.hpp index 247775e3e7..83eb5c1ec3 100644 --- a/components/detournavigator/cachedrecastmeshmanager.hpp +++ b/components/detournavigator/cachedrecastmeshmanager.hpp @@ -18,7 +18,7 @@ namespace DetourNavigator bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const osg::Vec3f& shift); - std::optional removeWater(const osg::Vec2i& cellPosition); + std::optional removeWater(const osg::Vec2i& cellPosition); std::optional removeObject(const ObjectId id); diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index ba1e93f50e..9c0f726540 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -34,10 +34,10 @@ namespace osg::Vec3f mMax; }; - WaterBounds getWaterBounds(const Water& water, const Settings& settings, + WaterBounds getWaterBounds(const Cell& water, const Settings& settings, const osg::Vec3f& agentHalfExtents) { - if (water.mCellSize == std::numeric_limits::max()) + if (water.mSize == std::numeric_limits::max()) { const auto transform = getSwimLevelTransform(settings, water.mShift, agentHalfExtents.z()); const auto min = toNavMeshCoordinates(settings, Misc::Convert::makeOsgVec3f(transform(btVector3(-1, -1, 0)))); @@ -50,7 +50,7 @@ namespace else { const auto transform = getSwimLevelTransform(settings, water.mShift, agentHalfExtents.z()); - const auto halfCellSize = water.mCellSize / 2.0f; + const auto halfCellSize = water.mSize / 2.0f; return WaterBounds { toNavMeshCoordinates(settings, Misc::Convert::makeOsgVec3f(transform(btVector3(-halfCellSize, -halfCellSize, 0)))), toNavMeshCoordinates(settings, Misc::Convert::makeOsgVec3f(transform(btVector3(halfCellSize, halfCellSize, 0)))) diff --git a/components/detournavigator/navmeshmanager.cpp b/components/detournavigator/navmeshmanager.cpp index 767dfd59aa..f2dd814d46 100644 --- a/components/detournavigator/navmeshmanager.cpp +++ b/components/detournavigator/navmeshmanager.cpp @@ -85,7 +85,7 @@ namespace DetourNavigator const auto water = mRecastMeshManager.removeWater(cellPosition); if (!water) return false; - addChangedTiles(water->mCellSize, water->mShift, ChangeType::remove); + addChangedTiles(water->mSize, water->mShift, ChangeType::remove); return true; } diff --git a/components/detournavigator/navmeshtilescache.hpp b/components/detournavigator/navmeshtilescache.hpp index 974420c158..d218ffdcee 100644 --- a/components/detournavigator/navmeshtilescache.hpp +++ b/components/detournavigator/navmeshtilescache.hpp @@ -23,7 +23,7 @@ namespace DetourNavigator struct RecastMeshData { Mesh mMesh; - std::vector mWater; + std::vector mWater; }; inline bool operator <(const RecastMeshData& lhs, const RecastMeshData& rhs) diff --git a/components/detournavigator/recastmesh.cpp b/components/detournavigator/recastmesh.cpp index 354be8207b..bf7a97caa8 100644 --- a/components/detournavigator/recastmesh.cpp +++ b/components/detournavigator/recastmesh.cpp @@ -18,7 +18,7 @@ namespace DetourNavigator mAreaTypes = std::move(areaTypes); } - RecastMesh::RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector water) + RecastMesh::RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector water) : mGeneration(generation) , mRevision(revision) , mMesh(std::move(mesh)) diff --git a/components/detournavigator/recastmesh.hpp b/components/detournavigator/recastmesh.hpp index c1d01e48fd..f316abf653 100644 --- a/components/detournavigator/recastmesh.hpp +++ b/components/detournavigator/recastmesh.hpp @@ -45,16 +45,16 @@ namespace DetourNavigator } }; - struct Water + struct Cell { - int mCellSize; + int mSize; osg::Vec3f mShift; }; class RecastMesh { public: - RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector water); + RecastMesh(std::size_t generation, std::size_t revision, Mesh mesh, std::vector water); std::size_t getGeneration() const { @@ -68,7 +68,7 @@ namespace DetourNavigator const Mesh& getMesh() const noexcept { return mMesh; } - const std::vector& getWater() const + const std::vector& getWater() const { return mWater; } @@ -82,7 +82,7 @@ namespace DetourNavigator std::size_t mGeneration; std::size_t mRevision; Mesh mMesh; - std::vector mWater; + std::vector mWater; Bounds mBounds; friend inline bool operator <(const RecastMesh& lhs, const RecastMesh& rhs) noexcept @@ -92,13 +92,13 @@ namespace DetourNavigator friend inline std::size_t getSize(const RecastMesh& value) noexcept { - return getSize(value.mMesh) + value.mWater.size() * sizeof(Water); + return getSize(value.mMesh) + value.mWater.size() * sizeof(Cell); } }; - inline bool operator<(const Water& lhs, const Water& rhs) noexcept + inline bool operator<(const Cell& lhs, const Cell& rhs) noexcept { - return std::tie(lhs.mCellSize, lhs.mShift) < std::tie(rhs.mCellSize, rhs.mShift); + return std::tie(lhs.mSize, lhs.mShift) < std::tie(rhs.mSize, rhs.mShift); } } diff --git a/components/detournavigator/recastmeshbuilder.cpp b/components/detournavigator/recastmeshbuilder.cpp index 1b2b5b08cd..b47d823199 100644 --- a/components/detournavigator/recastmeshbuilder.cpp +++ b/components/detournavigator/recastmeshbuilder.cpp @@ -160,7 +160,7 @@ namespace DetourNavigator void RecastMeshBuilder::addWater(const int cellSize, const osg::Vec3f& shift) { - mWater.push_back(Water {cellSize, shift}); + mWater.push_back(Cell {cellSize, shift}); } std::shared_ptr RecastMeshBuilder::create(std::size_t generation, std::size_t revision) && diff --git a/components/detournavigator/recastmeshbuilder.hpp b/components/detournavigator/recastmeshbuilder.hpp index 95dfc9cb52..d08ff94418 100644 --- a/components/detournavigator/recastmeshbuilder.hpp +++ b/components/detournavigator/recastmeshbuilder.hpp @@ -56,7 +56,7 @@ namespace DetourNavigator private: const TileBounds mBounds; std::vector mTriangles; - std::vector mWater; + std::vector mWater; void addObject(const btConcaveShape& shape, const btTransform& transform, btTriangleCallback&& callback); diff --git a/components/detournavigator/recastmeshmanager.cpp b/components/detournavigator/recastmeshmanager.cpp index 336ecf3fe5..e8ecee6027 100644 --- a/components/detournavigator/recastmeshmanager.cpp +++ b/components/detournavigator/recastmeshmanager.cpp @@ -49,19 +49,19 @@ namespace DetourNavigator bool RecastMeshManager::addWater(const osg::Vec2i& cellPosition, const int cellSize, const osg::Vec3f& shift) { - if (!mWater.emplace(cellPosition, Water {cellSize, shift}).second) + if (!mWater.emplace(cellPosition, Cell {cellSize, shift}).second) return false; ++mRevision; return true; } - std::optional RecastMeshManager::removeWater(const osg::Vec2i& cellPosition) + std::optional RecastMeshManager::removeWater(const osg::Vec2i& cellPosition) { const auto water = mWater.find(cellPosition); if (water == mWater.end()) return std::nullopt; ++mRevision; - const Water result = water->second; + const Cell result = water->second; mWater.erase(water); return result; } @@ -73,7 +73,7 @@ namespace DetourNavigator tileBounds.mMax /= mSettings.mRecastScaleFactor; RecastMeshBuilder builder(tileBounds); for (const auto& [k, v] : mWater) - builder.addWater(v.mCellSize, v.mShift); + builder.addWater(v.mSize, v.mShift); for (const auto& [k, object] : mObjects) { const RecastMeshObject& v = object.getImpl(); diff --git a/components/detournavigator/recastmeshmanager.hpp b/components/detournavigator/recastmeshmanager.hpp index bcb716353a..266d6a9385 100644 --- a/components/detournavigator/recastmeshmanager.hpp +++ b/components/detournavigator/recastmeshmanager.hpp @@ -39,7 +39,7 @@ namespace DetourNavigator bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const osg::Vec3f& shift); - std::optional removeWater(const osg::Vec2i& cellPosition); + std::optional removeWater(const osg::Vec2i& cellPosition); std::optional removeObject(const ObjectId id); @@ -63,7 +63,7 @@ namespace DetourNavigator std::size_t mGeneration; TileBounds mTileBounds; std::map mObjects; - std::map mWater; + std::map mWater; std::optional mLastNavMeshReportedChange; std::optional mLastNavMeshReport; }; diff --git a/components/detournavigator/tilecachedrecastmeshmanager.cpp b/components/detournavigator/tilecachedrecastmeshmanager.cpp index 15851d7daa..1292e31d4e 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.cpp @@ -102,12 +102,12 @@ namespace DetourNavigator return result; } - std::optional TileCachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) + std::optional TileCachedRecastMeshManager::removeWater(const osg::Vec2i& cellPosition) { const auto object = mWaterTilesPositions.find(cellPosition); if (object == mWaterTilesPositions.end()) return std::nullopt; - std::optional result; + std::optional result; for (const auto& tilePosition : object->second) { const auto tiles = mTiles.lock(); diff --git a/components/detournavigator/tilecachedrecastmeshmanager.hpp b/components/detournavigator/tilecachedrecastmeshmanager.hpp index 2c0faeca7d..4ea705f4cd 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.hpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.hpp @@ -78,7 +78,7 @@ namespace DetourNavigator bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const osg::Vec3f& shift); - std::optional removeWater(const osg::Vec2i& cellPosition); + std::optional removeWater(const osg::Vec2i& cellPosition); std::shared_ptr getMesh(const TilePosition& tilePosition);