From 05258ed644dbf8f9466fb3ea2e399781d8c85755 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 8 Aug 2021 17:59:34 +0200 Subject: [PATCH] Remove redundant TileCachedRecastMeshManager::hasTile function It's used only for tests. getMesh is a valid replacement. --- .../tilecachedrecastmeshmanager.cpp | 18 ++++++------------ .../tilecachedrecastmeshmanager.cpp | 5 ----- .../tilecachedrecastmeshmanager.hpp | 2 -- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp b/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp index 51580906ce..6209ec9c2a 100644 --- a/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/apps/openmw_test_suite/detournavigator/tilecachedrecastmeshmanager.cpp @@ -38,12 +38,6 @@ namespace EXPECT_EQ(manager.getMesh(TilePosition(0, 0)), nullptr); } - TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, has_tile_for_empty_should_return_false) - { - TileCachedRecastMeshManager manager(mSettings); - EXPECT_FALSE(manager.hasTile(TilePosition(0, 0))); - } - TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_revision_for_empty_should_return_zero) { const TileCachedRecastMeshManager manager(mSettings); @@ -83,7 +77,7 @@ namespace ASSERT_TRUE(manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground)); for (int x = -1; x < 1; ++x) for (int y = -1; y < 1; ++y) - ASSERT_TRUE(manager.hasTile(TilePosition(x, y))); + ASSERT_NE(manager.getMesh(TilePosition(x, y)), nullptr); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, update_object_for_changed_object_should_return_changed_tiles) @@ -281,7 +275,7 @@ namespace ASSERT_TRUE(manager.addWater(cellPosition, cellSize, osg::Vec3f())); for (int x = -6; x < 6; ++x) for (int y = -6; y < 6; ++y) - ASSERT_TRUE(manager.hasTile(TilePosition(x, y))); + ASSERT_NE(manager.getMesh(TilePosition(x, y)), nullptr); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_max_int_should_not_add_new_tiles) @@ -295,7 +289,7 @@ namespace ASSERT_TRUE(manager.addWater(cellPosition, cellSize, osg::Vec3f())); for (int x = -6; x < 6; ++x) for (int y = -6; y < 6; ++y) - ASSERT_EQ(manager.hasTile(TilePosition(x, y)), -1 <= x && x <= 0 && -1 <= y && y <= 0); + ASSERT_EQ(manager.getMesh(TilePosition(x, y)) != nullptr, -1 <= x && x <= 0 && -1 <= y && y <= 0); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_absent_cell_should_return_nullopt) @@ -324,7 +318,7 @@ namespace ASSERT_TRUE(manager.removeWater(cellPosition)); for (int x = -6; x < 6; ++x) for (int y = -6; y < 6; ++y) - ASSERT_FALSE(manager.hasTile(TilePosition(x, y))); + ASSERT_EQ(manager.getMesh(TilePosition(x, y)), nullptr); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_leave_not_empty_tiles) @@ -339,7 +333,7 @@ namespace ASSERT_TRUE(manager.removeWater(cellPosition)); for (int x = -6; x < 6; ++x) for (int y = -6; y < 6; ++y) - ASSERT_EQ(manager.hasTile(TilePosition(x, y)), -1 <= x && x <= 0 && -1 <= y && y <= 0); + ASSERT_EQ(manager.getMesh(TilePosition(x, y)) != nullptr, -1 <= x && x <= 0 && -1 <= y && y <= 0); } TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_object_should_not_remove_tile_with_water) @@ -354,6 +348,6 @@ namespace ASSERT_TRUE(manager.removeObject(ObjectId(&boxShape))); for (int x = -6; x < 6; ++x) for (int y = -6; y < 6; ++y) - ASSERT_TRUE(manager.hasTile(TilePosition(x, y))); + ASSERT_NE(manager.getMesh(TilePosition(x, y)), nullptr); } } diff --git a/components/detournavigator/tilecachedrecastmeshmanager.cpp b/components/detournavigator/tilecachedrecastmeshmanager.cpp index 8033ca89ac..38314f08a5 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.cpp @@ -205,11 +205,6 @@ namespace DetourNavigator return manager->getMesh(); } - bool TileCachedRecastMeshManager::hasTile(const TilePosition& tilePosition) const - { - return mTiles.lockConst()->count(tilePosition); - } - std::size_t TileCachedRecastMeshManager::getRevision() const { return mRevision; diff --git a/components/detournavigator/tilecachedrecastmeshmanager.hpp b/components/detournavigator/tilecachedrecastmeshmanager.hpp index f10260a4dd..f6bc40d668 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.hpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.hpp @@ -88,8 +88,6 @@ namespace DetourNavigator std::shared_ptr getMesh(const TilePosition& tilePosition) const; - bool hasTile(const TilePosition& tilePosition) const; - template void forEachTile(Function&& function) const {