From ce5fbd6b6816547c5791d5adfacbf4deaed3ba21 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 28 Apr 2023 13:28:52 +0200 Subject: [PATCH 1/5] Write separator between Detour status flags --- components/detournavigator/debug.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/detournavigator/debug.cpp b/components/detournavigator/debug.cpp index 8aa506fb3b..5a0d8779fd 100644 --- a/components/detournavigator/debug.cpp +++ b/components/detournavigator/debug.cpp @@ -114,9 +114,17 @@ namespace DetourNavigator std::ostream& operator<<(std::ostream& stream, const WriteDtStatus& value) { - for (const auto& status : dtStatuses) - if (value.mStatus & status.mStatus) - stream << status.mString; + bool first = true; + for (const auto& v : dtStatuses) + { + if ((value.mStatus & v.mStatus) == 0) + continue; + if (first) + first = false; + else + stream << " | "; + stream << v.mString; + } return stream; } From dd08154b231d0258ae267f425ca89b247287db6c Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 28 Apr 2023 13:44:09 +0200 Subject: [PATCH 2/5] Add operator<< for DetourNavigator::AreaCosts --- components/detournavigator/debug.cpp | 7 +++++++ components/detournavigator/debug.hpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/components/detournavigator/debug.cpp b/components/detournavigator/debug.cpp index 5a0d8779fd..0eb47d8f88 100644 --- a/components/detournavigator/debug.cpp +++ b/components/detournavigator/debug.cpp @@ -215,6 +215,13 @@ namespace DetourNavigator return stream << "TilesPositionsRange {" << value.mBegin << ", " << value.mEnd << "}"; } + std::ostream& operator<<(std::ostream& stream, const AreaCosts& value) + { + return stream << "AreaCosts {" + << ".mWater = " << value.mWater << ", .mDoor = " << value.mDoor + << ", .mPathgrid = " << value.mPathgrid << ", .mGround = " << value.mGround << "}"; + } + void writeToFile(const RecastMesh& recastMesh, const std::string& pathPrefix, const std::string& revision, const RecastSettings& settings) { diff --git a/components/detournavigator/debug.hpp b/components/detournavigator/debug.hpp index 943e0d7b7d..b6d8438f83 100644 --- a/components/detournavigator/debug.hpp +++ b/components/detournavigator/debug.hpp @@ -20,6 +20,7 @@ namespace DetourNavigator { struct Version; struct TilesPositionsRange; + struct AreaCosts; std::ostream& operator<<(std::ostream& stream, const TileBounds& value); @@ -61,6 +62,8 @@ namespace DetourNavigator std::ostream& operator<<(std::ostream& stream, const TilesPositionsRange& value); + std::ostream& operator<<(std::ostream& stream, const AreaCosts& value); + class RecastMesh; struct RecastSettings; From f9e9368fda0de48b93bdfbc82026556f12ba6c32 Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 8 May 2023 22:28:32 +0200 Subject: [PATCH 3/5] Add operator<< for DetourSettings --- components/detournavigator/debug.cpp | 9 +++++++++ components/detournavigator/debug.hpp | 3 +++ 2 files changed, 12 insertions(+) diff --git a/components/detournavigator/debug.cpp b/components/detournavigator/debug.cpp index 0eb47d8f88..9aa28c84f2 100644 --- a/components/detournavigator/debug.cpp +++ b/components/detournavigator/debug.cpp @@ -222,6 +222,15 @@ namespace DetourNavigator << ", .mPathgrid = " << value.mPathgrid << ", .mGround = " << value.mGround << "}"; } + std::ostream& operator<<(std::ostream& stream, const DetourSettings& value) + { + return stream << "DetourSettings {" + << ".mMaxPolys = " << value.mMaxPolys + << ", .mMaxNavMeshQueryNodes = " << value.mMaxNavMeshQueryNodes + << ", .mMaxPolygonPathSize = " << value.mMaxPolygonPathSize + << ", .mMaxSmoothPathSize = " << value.mMaxSmoothPathSize << "}"; + } + void writeToFile(const RecastMesh& recastMesh, const std::string& pathPrefix, const std::string& revision, const RecastSettings& settings) { diff --git a/components/detournavigator/debug.hpp b/components/detournavigator/debug.hpp index b6d8438f83..84a9e88ca3 100644 --- a/components/detournavigator/debug.hpp +++ b/components/detournavigator/debug.hpp @@ -21,6 +21,7 @@ namespace DetourNavigator struct Version; struct TilesPositionsRange; struct AreaCosts; + struct DetourSettings; std::ostream& operator<<(std::ostream& stream, const TileBounds& value); @@ -64,6 +65,8 @@ namespace DetourNavigator std::ostream& operator<<(std::ostream& stream, const AreaCosts& value); + std::ostream& operator<<(std::ostream& stream, const DetourSettings& value); + class RecastMesh; struct RecastSettings; From e6e6b65ab371a09fbd93874f5ab12733141ebeba Mon Sep 17 00:00:00 2001 From: elsid Date: Mon, 8 May 2023 22:26:37 +0200 Subject: [PATCH 4/5] Remove redundant manipulators --- apps/openmw_test_suite/detournavigator/operators.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/openmw_test_suite/detournavigator/operators.hpp b/apps/openmw_test_suite/detournavigator/operators.hpp index 356e5eca04..4e42af78e4 100644 --- a/apps/openmw_test_suite/detournavigator/operators.hpp +++ b/apps/openmw_test_suite/detournavigator/operators.hpp @@ -38,9 +38,8 @@ namespace testing template <> inline testing::Message& Message::operator<<(const osg::Vec3f& value) { - return (*this) << "Vec3fEq(" << std::setprecision(std::numeric_limits::max_exponent10) << value.x() - << ", " << std::setprecision(std::numeric_limits::max_exponent10) << value.y() << ", " - << std::setprecision(std::numeric_limits::max_exponent10) << value.z() << ')'; + return (*this) << std::setprecision(std::numeric_limits::max_exponent10) << "Vec3fEq(" << value.x() + << ", " << value.y() << ", " << value.z() << ')'; } template <> From 180dd7dc64af8c23f68fdab874970af1c115b053 Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 10 Jun 2023 13:23:47 +0200 Subject: [PATCH 5/5] Log worldspace in RecastContext --- components/detournavigator/asyncnavmeshupdater.cpp | 8 ++++---- components/detournavigator/generatenavmeshtile.cpp | 3 ++- components/detournavigator/makenavmesh.cpp | 5 +++-- components/detournavigator/makenavmesh.hpp | 3 ++- components/detournavigator/recastcontext.cpp | 12 +++++++----- components/detournavigator/recastcontext.hpp | 3 ++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/components/detournavigator/asyncnavmeshupdater.cpp b/components/detournavigator/asyncnavmeshupdater.cpp index f30b325e60..89f75113e6 100644 --- a/components/detournavigator/asyncnavmeshupdater.cpp +++ b/components/detournavigator/asyncnavmeshupdater.cpp @@ -433,8 +433,8 @@ namespace DetourNavigator return JobStatus::MemoryCacheMiss; } - preparedNavMeshData - = prepareNavMeshTileData(*recastMesh, job.mChangedTile, job.mAgentBounds, mSettings.get().mRecast); + preparedNavMeshData = prepareNavMeshTileData( + *recastMesh, job.mWorldspace, job.mChangedTile, job.mAgentBounds, mSettings.get().mRecast); if (preparedNavMeshData == nullptr) { @@ -483,8 +483,8 @@ namespace DetourNavigator if (preparedNavMeshData == nullptr) { - preparedNavMeshData - = prepareNavMeshTileData(*job.mRecastMesh, job.mChangedTile, job.mAgentBounds, mSettings.get().mRecast); + preparedNavMeshData = prepareNavMeshTileData( + *job.mRecastMesh, job.mWorldspace, job.mChangedTile, job.mAgentBounds, mSettings.get().mRecast); generatedNavMeshData = true; } diff --git a/components/detournavigator/generatenavmeshtile.cpp b/components/detournavigator/generatenavmeshtile.cpp index 408c28cfba..a96a554302 100644 --- a/components/detournavigator/generatenavmeshtile.cpp +++ b/components/detournavigator/generatenavmeshtile.cpp @@ -79,7 +79,8 @@ namespace DetourNavigator return; } - const auto data = prepareNavMeshTileData(*recastMesh, mTilePosition, mAgentBounds, mSettings.mRecast); + const auto data + = prepareNavMeshTileData(*recastMesh, mWorldspace, mTilePosition, mAgentBounds, mSettings.mRecast); if (data == nullptr) return; diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index a389fe55b8..44ba14e4e5 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -517,9 +517,10 @@ namespace DetourNavigator namespace DetourNavigator { std::unique_ptr prepareNavMeshTileData(const RecastMesh& recastMesh, - const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings) + std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds, + const RecastSettings& settings) { - RecastContext context(tilePosition, agentBounds); + RecastContext context(worldspace, tilePosition, agentBounds); const auto [minZ, maxZ] = getBoundsByZ(recastMesh, agentBounds.mHalfExtents.z(), settings); diff --git a/components/detournavigator/makenavmesh.hpp b/components/detournavigator/makenavmesh.hpp index 01542d066d..25bbca6d3c 100644 --- a/components/detournavigator/makenavmesh.hpp +++ b/components/detournavigator/makenavmesh.hpp @@ -42,7 +42,8 @@ namespace DetourNavigator } std::unique_ptr prepareNavMeshTileData(const RecastMesh& recastMesh, - const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings); + std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds, + const RecastSettings& settings); NavMeshData makeNavMeshTileData(const PreparedNavMeshData& data, const std::vector& offMeshConnections, const AgentBounds& agentBounds, diff --git a/components/detournavigator/recastcontext.cpp b/components/detournavigator/recastcontext.cpp index 6f3e2abbd8..7ac7bcb66e 100644 --- a/components/detournavigator/recastcontext.cpp +++ b/components/detournavigator/recastcontext.cpp @@ -23,17 +23,19 @@ namespace DetourNavigator return Debug::Debug; } - std::string formatPrefix(const TilePosition& tilePosition, const AgentBounds& agentBounds) + std::string formatPrefix( + std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds) { std::ostringstream stream; - stream << "Tile position: " << tilePosition.x() << ", " << tilePosition.y() - << "; agent bounds: " << agentBounds << "; "; + stream << "Worldspace: " << worldspace << "; tile position: " << tilePosition.x() << ", " + << tilePosition.y() << "; agent bounds: " << agentBounds << "; "; return stream.str(); } } - RecastContext::RecastContext(const TilePosition& tilePosition, const AgentBounds& agentBounds) - : mPrefix(formatPrefix(tilePosition, agentBounds)) + RecastContext::RecastContext( + std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds) + : mPrefix(formatPrefix(worldspace, tilePosition, agentBounds)) { } diff --git a/components/detournavigator/recastcontext.hpp b/components/detournavigator/recastcontext.hpp index d01bb47601..3d65bbe95a 100644 --- a/components/detournavigator/recastcontext.hpp +++ b/components/detournavigator/recastcontext.hpp @@ -14,7 +14,8 @@ namespace DetourNavigator class RecastContext final : public rcContext { public: - explicit RecastContext(const TilePosition& tilePosition, const AgentBounds& agentBounds); + explicit RecastContext( + std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds); const std::string& getPrefix() const { return mPrefix; }