From 1a5932a6690583ae104aceb6b3950fbb890fe1f6 Mon Sep 17 00:00:00 2001 From: elsid Date: Sun, 26 Jun 2022 19:36:03 +0200 Subject: [PATCH] Move std::ostream& operator<< to .cpp --- apps/openmw/mwmechanics/aiwander.cpp | 2 + apps/openmw/mwmechanics/pathfinding.cpp | 3 + apps/openmw/mwworld/scene.cpp | 1 - apps/openmw/mwworld/worldimp.cpp | 2 + components/bullethelpers/debug.hpp | 70 +++++++ components/bullethelpers/operators.hpp | 65 +------ components/detournavigator/areatype.hpp | 15 -- .../detournavigator/asyncnavmeshupdater.cpp | 12 ++ .../detournavigator/asyncnavmeshupdater.hpp | 12 +- components/detournavigator/changetype.hpp | 18 -- components/detournavigator/debug.cpp | 179 ++++++++++++++++++ components/detournavigator/debug.hpp | 99 ++++------ components/detournavigator/dtstatus.hpp | 38 ---- components/detournavigator/findsmoothpath.hpp | 2 - components/detournavigator/flags.hpp | 50 ----- .../detournavigator/navmeshcacheitem.cpp | 29 ++- .../detournavigator/navmeshcacheitem.hpp | 29 +-- components/detournavigator/navmeshmanager.cpp | 2 + components/sceneutil/detourdebugdraw.cpp | 4 - 19 files changed, 337 insertions(+), 295 deletions(-) create mode 100644 components/bullethelpers/debug.hpp delete mode 100644 components/detournavigator/dtstatus.hpp diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 0bd424785b..f6c46945b1 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -2,6 +2,8 @@ #include +#include + #include #include #include diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 4f4c35bb40..9a75585cc1 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -3,7 +3,10 @@ #include #include +#include + #include +#include #include #include #include diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 57eec9d2dd..f23c086827 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 628ac60727..bd89bca0df 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -6,6 +6,8 @@ #include +#include + #include #include diff --git a/components/bullethelpers/debug.hpp b/components/bullethelpers/debug.hpp new file mode 100644 index 0000000000..564616043d --- /dev/null +++ b/components/bullethelpers/debug.hpp @@ -0,0 +1,70 @@ +#ifndef OPENMW_COMPONENTS_BULLETHELPERS_DEBUG_H +#define OPENMW_COMPONENTS_BULLETHELPERS_DEBUG_H + +#include +#include +#include + +#include + +#include + +inline std::ostream& operator <<(std::ostream& stream, const btVector3& value) +{ + return stream << "btVector3(" << 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() + << ')'; +} + +inline std::ostream& operator <<(std::ostream& stream, BroadphaseNativeTypes value) +{ + switch (value) + { +#ifndef SHAPE_NAME +#define SHAPE_NAME(name) case name: return stream << #name; + SHAPE_NAME(BOX_SHAPE_PROXYTYPE) + SHAPE_NAME(TRIANGLE_SHAPE_PROXYTYPE) + SHAPE_NAME(TETRAHEDRAL_SHAPE_PROXYTYPE) + SHAPE_NAME(CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE) + SHAPE_NAME(CONVEX_HULL_SHAPE_PROXYTYPE) + SHAPE_NAME(CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE) + SHAPE_NAME(CUSTOM_POLYHEDRAL_SHAPE_TYPE) + SHAPE_NAME(IMPLICIT_CONVEX_SHAPES_START_HERE) + SHAPE_NAME(SPHERE_SHAPE_PROXYTYPE) + SHAPE_NAME(MULTI_SPHERE_SHAPE_PROXYTYPE) + SHAPE_NAME(CAPSULE_SHAPE_PROXYTYPE) + SHAPE_NAME(CONE_SHAPE_PROXYTYPE) + SHAPE_NAME(CONVEX_SHAPE_PROXYTYPE) + SHAPE_NAME(CYLINDER_SHAPE_PROXYTYPE) + SHAPE_NAME(UNIFORM_SCALING_SHAPE_PROXYTYPE) + SHAPE_NAME(MINKOWSKI_SUM_SHAPE_PROXYTYPE) + SHAPE_NAME(MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE) + SHAPE_NAME(BOX_2D_SHAPE_PROXYTYPE) + SHAPE_NAME(CONVEX_2D_SHAPE_PROXYTYPE) + SHAPE_NAME(CUSTOM_CONVEX_SHAPE_TYPE) + SHAPE_NAME(CONCAVE_SHAPES_START_HERE) + SHAPE_NAME(TRIANGLE_MESH_SHAPE_PROXYTYPE) + SHAPE_NAME(SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE) + SHAPE_NAME(FAST_CONCAVE_MESH_PROXYTYPE) + SHAPE_NAME(TERRAIN_SHAPE_PROXYTYPE) + SHAPE_NAME(GIMPACT_SHAPE_PROXYTYPE) + SHAPE_NAME(MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE) + SHAPE_NAME(EMPTY_SHAPE_PROXYTYPE) + SHAPE_NAME(STATIC_PLANE_PROXYTYPE) + SHAPE_NAME(CUSTOM_CONCAVE_SHAPE_TYPE) + SHAPE_NAME(CONCAVE_SHAPES_END_HERE) + SHAPE_NAME(COMPOUND_SHAPE_PROXYTYPE) + SHAPE_NAME(SOFTBODY_SHAPE_PROXYTYPE) + SHAPE_NAME(HFFLUID_SHAPE_PROXYTYPE) + SHAPE_NAME(HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE) + SHAPE_NAME(INVALID_SHAPE_PROXYTYPE) + SHAPE_NAME(MAX_BROADPHASE_COLLISION_TYPES) +#undef SHAPE_NAME +#endif + default: + return stream << "undefined(" << static_cast(value) << ")"; + } +} + +#endif diff --git a/components/bullethelpers/operators.hpp b/components/bullethelpers/operators.hpp index 1f5aa55425..f1e52938db 100644 --- a/components/bullethelpers/operators.hpp +++ b/components/bullethelpers/operators.hpp @@ -1,73 +1,10 @@ #ifndef OPENMW_COMPONENTS_BULLETHELPERS_OPERATORS_H #define OPENMW_COMPONENTS_BULLETHELPERS_OPERATORS_H -#include -#include -#include #include -#include - +#include #include -#include - -inline std::ostream& operator <<(std::ostream& stream, const btVector3& value) -{ - return stream << "btVector3(" << 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() - << ')'; -} - -inline std::ostream& operator <<(std::ostream& stream, BroadphaseNativeTypes value) -{ - switch (value) - { -#ifndef SHAPE_NAME -#define SHAPE_NAME(name) case name: return stream << #name; - SHAPE_NAME(BOX_SHAPE_PROXYTYPE) - SHAPE_NAME(TRIANGLE_SHAPE_PROXYTYPE) - SHAPE_NAME(TETRAHEDRAL_SHAPE_PROXYTYPE) - SHAPE_NAME(CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE) - SHAPE_NAME(CONVEX_HULL_SHAPE_PROXYTYPE) - SHAPE_NAME(CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE) - SHAPE_NAME(CUSTOM_POLYHEDRAL_SHAPE_TYPE) - SHAPE_NAME(IMPLICIT_CONVEX_SHAPES_START_HERE) - SHAPE_NAME(SPHERE_SHAPE_PROXYTYPE) - SHAPE_NAME(MULTI_SPHERE_SHAPE_PROXYTYPE) - SHAPE_NAME(CAPSULE_SHAPE_PROXYTYPE) - SHAPE_NAME(CONE_SHAPE_PROXYTYPE) - SHAPE_NAME(CONVEX_SHAPE_PROXYTYPE) - SHAPE_NAME(CYLINDER_SHAPE_PROXYTYPE) - SHAPE_NAME(UNIFORM_SCALING_SHAPE_PROXYTYPE) - SHAPE_NAME(MINKOWSKI_SUM_SHAPE_PROXYTYPE) - SHAPE_NAME(MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE) - SHAPE_NAME(BOX_2D_SHAPE_PROXYTYPE) - SHAPE_NAME(CONVEX_2D_SHAPE_PROXYTYPE) - SHAPE_NAME(CUSTOM_CONVEX_SHAPE_TYPE) - SHAPE_NAME(CONCAVE_SHAPES_START_HERE) - SHAPE_NAME(TRIANGLE_MESH_SHAPE_PROXYTYPE) - SHAPE_NAME(SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE) - SHAPE_NAME(FAST_CONCAVE_MESH_PROXYTYPE) - SHAPE_NAME(TERRAIN_SHAPE_PROXYTYPE) - SHAPE_NAME(GIMPACT_SHAPE_PROXYTYPE) - SHAPE_NAME(MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE) - SHAPE_NAME(EMPTY_SHAPE_PROXYTYPE) - SHAPE_NAME(STATIC_PLANE_PROXYTYPE) - SHAPE_NAME(CUSTOM_CONCAVE_SHAPE_TYPE) - SHAPE_NAME(CONCAVE_SHAPES_END_HERE) - SHAPE_NAME(COMPOUND_SHAPE_PROXYTYPE) - SHAPE_NAME(SOFTBODY_SHAPE_PROXYTYPE) - SHAPE_NAME(HFFLUID_SHAPE_PROXYTYPE) - SHAPE_NAME(HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE) - SHAPE_NAME(INVALID_SHAPE_PROXYTYPE) - SHAPE_NAME(MAX_BROADPHASE_COLLISION_TYPES) -#undef SHAPE_NAME -#endif - default: - return stream << "undefined(" << static_cast(value) << ")"; - } -} inline bool operator <(const btVector3& lhs, const btVector3& rhs) { diff --git a/components/detournavigator/areatype.hpp b/components/detournavigator/areatype.hpp index 125b7ed7b9..9d99421af0 100644 --- a/components/detournavigator/areatype.hpp +++ b/components/detournavigator/areatype.hpp @@ -3,8 +3,6 @@ #include -#include - namespace DetourNavigator { enum AreaType : unsigned char @@ -23,19 +21,6 @@ namespace DetourNavigator float mPathgrid = 1.0f; float mGround = 1.0f; }; - - inline std::ostream& operator<<(std::ostream& stream, AreaType value) - { - switch (value) - { - case AreaType_null: return stream << "null"; - case AreaType_water: return stream << "water"; - case AreaType_door: return stream << "door"; - case AreaType_pathgrid: return stream << "pathgrid"; - case AreaType_ground: return stream << "ground"; - } - return stream << "unknown area type (" << static_cast>(value) << ")"; - } } #endif diff --git a/components/detournavigator/asyncnavmeshupdater.cpp b/components/detournavigator/asyncnavmeshupdater.cpp index b9424e406a..e6b07d3f36 100644 --- a/components/detournavigator/asyncnavmeshupdater.cpp +++ b/components/detournavigator/asyncnavmeshupdater.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -112,6 +113,17 @@ namespace DetourNavigator } } + std::ostream& operator<<(std::ostream& stream, JobStatus value) + { + switch (value) + { + case JobStatus::Done: return stream << "JobStatus::Done"; + case JobStatus::Fail: return stream << "JobStatus::Fail"; + case JobStatus::MemoryCacheMiss: return stream << "JobStatus::MemoryCacheMiss"; + } + return stream << "JobStatus::" << static_cast>(value); + } + Job::Job(const AgentBounds& agentBounds, std::weak_ptr navMeshCacheItem, std::string_view worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer, std::chrono::steady_clock::time_point processTime) diff --git a/components/detournavigator/asyncnavmeshupdater.hpp b/components/detournavigator/asyncnavmeshupdater.hpp index d0850f0249..abdd235678 100644 --- a/components/detournavigator/asyncnavmeshupdater.hpp +++ b/components/detournavigator/asyncnavmeshupdater.hpp @@ -24,6 +24,7 @@ #include #include #include +#include class dtNavMesh; @@ -72,16 +73,7 @@ namespace DetourNavigator MemoryCacheMiss, }; - inline std::ostream& operator<<(std::ostream& stream, JobStatus value) - { - switch (value) - { - case JobStatus::Done: return stream << "JobStatus::Done"; - case JobStatus::Fail: return stream << "JobStatus::Fail"; - case JobStatus::MemoryCacheMiss: return stream << "JobStatus::MemoryCacheMiss"; - } - return stream << "JobStatus::" << static_cast>(value); - } + std::ostream& operator<<(std::ostream& stream, JobStatus value); class DbJobQueue { diff --git a/components/detournavigator/changetype.hpp b/components/detournavigator/changetype.hpp index 1ede6aec13..15b3056e55 100644 --- a/components/detournavigator/changetype.hpp +++ b/components/detournavigator/changetype.hpp @@ -1,8 +1,6 @@ #ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_CHANGETYPE_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_CHANGETYPE_H -#include - namespace DetourNavigator { enum class ChangeType @@ -12,22 +10,6 @@ namespace DetourNavigator add = 2, update = 3, }; - - inline std::ostream& operator <<(std::ostream& stream, ChangeType value) - { - switch (value) - { - case ChangeType::remove: - return stream << "ChangeType::remove"; - case ChangeType::mixed: - return stream << "ChangeType::mixed"; - case ChangeType::add: - return stream << "ChangeType::add"; - case ChangeType::update: - return stream << "ChangeType::update"; - } - return stream << "ChangeType::" << static_cast(value); - } } #endif diff --git a/components/detournavigator/debug.cpp b/components/detournavigator/debug.cpp index 0ddd27da5e..c76e2bc562 100644 --- a/components/detournavigator/debug.cpp +++ b/components/detournavigator/debug.cpp @@ -4,13 +4,192 @@ #include "settings.hpp" #include "settingsutils.hpp" +#include + #include +#include + +#include #include #include +#include +#include +#include namespace DetourNavigator { + std::ostream& operator<<(std::ostream& stream, const TileBounds& value) + { + return stream << "TileBounds {" << value.mMin << ", " << value.mMax << "}"; + } + + std::ostream& operator<<(std::ostream& stream, Status value) + { +#define OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(name) \ + case Status::name: return stream << "DetourNavigator::Status::"#name; + switch (value) + { + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(Success) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(PartialPath) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(NavMeshNotFound) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(StartPolygonNotFound) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(EndPolygonNotFound) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(MoveAlongSurfaceFailed) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(FindPathOverPolygonsFailed) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(GetPolyHeightFailed) + OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(InitNavMeshQueryFailed) + } +#undef OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE + return stream << "DetourNavigator::Error::" << static_cast(value); + } + + std::ostream& operator<<(std::ostream& s, const Water& v) + { + return s << "Water {" << v.mCellSize << ", " << v.mLevel << "}"; + } + + std::ostream& operator<<(std::ostream& s, const CellWater& v) + { + return s << "CellWater {" << v.mCellPosition << ", " << v.mWater << "}"; + } + + std::ostream& operator<<(std::ostream& s, const FlatHeightfield& v) + { + return s << "FlatHeightfield {" << v.mCellPosition << ", " << v.mCellSize << ", " << v.mHeight << "}"; + } + + std::ostream& operator<<(std::ostream& s, const Heightfield& v) + { + s << "Heightfield {.mCellPosition=" << v.mCellPosition + << ", .mCellSize=" << v.mCellSize + << ", .mLength=" << static_cast(v.mLength) + << ", .mMinHeight=" << v.mMinHeight + << ", .mMaxHeight=" << v.mMaxHeight + << ", .mHeights={"; + for (float h : v.mHeights) + s << h << ", "; + s << "}"; + return s << ", .mOriginalSize=" << v.mOriginalSize << "}"; + } + + std::ostream& operator<<(std::ostream& s, CollisionShapeType v) + { + switch (v) + { + case CollisionShapeType::Aabb: return s << "AgentShapeType::Aabb"; + case CollisionShapeType::RotatingBox: return s << "AgentShapeType::RotatingBox"; + } + return s << "AgentShapeType::" << static_cast>(v); + } + + std::ostream& operator<<(std::ostream& s, const AgentBounds& v) + { + return s << "AgentBounds {" << v.mShapeType << ", " << v.mHalfExtents << "}"; + } + + namespace + { + struct StatusString + { + dtStatus mStatus; + std::string_view mString; + }; + } + + static constexpr std::array dtStatuses { + StatusString {DT_FAILURE, "DT_FAILURE"}, + StatusString {DT_SUCCESS, "DT_SUCCESS"}, + StatusString {DT_IN_PROGRESS, "DT_IN_PROGRESS"}, + StatusString {DT_WRONG_MAGIC, "DT_WRONG_MAGIC"}, + StatusString {DT_WRONG_VERSION, "DT_WRONG_VERSION"}, + StatusString {DT_OUT_OF_MEMORY, "DT_OUT_OF_MEMORY"}, + StatusString {DT_INVALID_PARAM, "DT_INVALID_PARAM"}, + StatusString {DT_BUFFER_TOO_SMALL, "DT_BUFFER_TOO_SMALL"}, + StatusString {DT_OUT_OF_NODES, "DT_OUT_OF_NODES"}, + StatusString {DT_PARTIAL_RESULT, "DT_PARTIAL_RESULT"}, + }; + + std::ostream& operator<<(std::ostream& stream, const WriteDtStatus& value) + { + for (const auto& status : dtStatuses) + if (value.mStatus & status.mStatus) + stream << status.mString; + return stream; + } + + std::ostream& operator<<(std::ostream& stream, const Flag value) + { + switch (value) + { + case Flag_none: + return stream << "none"; + case Flag_walk: + return stream << "walk"; + case Flag_swim: + return stream << "swim"; + case Flag_openDoor: + return stream << "openDoor"; + case Flag_usePathgrid: + return stream << "usePathgrid"; + } + + return stream; + } + + std::ostream& operator<<(std::ostream& stream, const WriteFlags& value) + { + if (value.mValue == Flag_none) + { + return stream << Flag_none; + } + else + { + bool first = true; + for (const auto flag : {Flag_walk, Flag_swim, Flag_openDoor, Flag_usePathgrid}) + { + if (value.mValue & flag) + { + if (!first) + stream << " | "; + first = false; + stream << flag; + } + } + + return stream; + } + } + + std::ostream& operator<<(std::ostream& stream, AreaType value) + { + switch (value) + { + case AreaType_null: return stream << "null"; + case AreaType_water: return stream << "water"; + case AreaType_door: return stream << "door"; + case AreaType_pathgrid: return stream << "pathgrid"; + case AreaType_ground: return stream << "ground"; + } + return stream << "unknown area type (" << static_cast>(value) << ")"; + } + + std::ostream& operator<<(std::ostream& stream, ChangeType value) + { + switch (value) + { + case ChangeType::remove: + return stream << "ChangeType::remove"; + case ChangeType::mixed: + return stream << "ChangeType::mixed"; + case ChangeType::add: + return stream << "ChangeType::add"; + case ChangeType::update: + return stream << "ChangeType::update"; + } + return stream << "ChangeType::" << static_cast(value); + } + 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 091e49821c..818be0616c 100644 --- a/components/detournavigator/debug.hpp +++ b/components/detournavigator/debug.hpp @@ -5,85 +5,54 @@ #include "status.hpp" #include "recastmesh.hpp" #include "agentbounds.hpp" +#include "flags.hpp" +#include "areatype.hpp" +#include "changetype.hpp" -#include - -#include +#include #include +#include class dtNavMesh; namespace DetourNavigator { - inline std::ostream& operator <<(std::ostream& stream, const TileBounds& value) - { - return stream << "TileBounds {" << value.mMin << ", " << value.mMax << "}"; - } + std::ostream& operator<<(std::ostream& stream, const TileBounds& value); - inline std::ostream& operator <<(std::ostream& stream, Status value) - { -#define OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(name) \ - case Status::name: return stream << "DetourNavigator::Status::"#name; - switch (value) - { - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(Success) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(PartialPath) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(NavMeshNotFound) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(StartPolygonNotFound) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(EndPolygonNotFound) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(MoveAlongSurfaceFailed) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(FindPathOverPolygonsFailed) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(GetPolyHeightFailed) - OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE(InitNavMeshQueryFailed) - } -#undef OPENMW_COMPONENTS_DETOURNAVIGATOR_DEBUG_STATUS_MESSAGE - return stream << "DetourNavigator::Error::" << static_cast(value); - } - - inline std::ostream& operator<<(std::ostream& s, const Water& v) - { - return s << "Water {" << v.mCellSize << ", " << v.mLevel << "}"; - } + std::ostream& operator<<(std::ostream& stream, Status value); - inline std::ostream& operator<<(std::ostream& s, const CellWater& v) - { - return s << "CellWater {" << v.mCellPosition << ", " << v.mWater << "}"; - } + std::ostream& operator<<(std::ostream& s, const Water& v); - inline std::ostream& operator<<(std::ostream& s, const FlatHeightfield& v) - { - return s << "FlatHeightfield {" << v.mCellPosition << ", " << v.mCellSize << ", " << v.mHeight << "}"; - } + std::ostream& operator<<(std::ostream& s, const CellWater& v); - inline std::ostream& operator<<(std::ostream& s, const Heightfield& v) - { - s << "Heightfield {.mCellPosition=" << v.mCellPosition - << ", .mCellSize=" << v.mCellSize - << ", .mLength=" << static_cast(v.mLength) - << ", .mMinHeight=" << v.mMinHeight - << ", .mMaxHeight=" << v.mMaxHeight - << ", .mHeights={"; - for (float h : v.mHeights) - s << h << ", "; - s << "}"; - return s << ", .mOriginalSize=" << v.mOriginalSize << "}"; - } - - inline std::ostream& operator<<(std::ostream& s, CollisionShapeType v) + std::ostream& operator<<(std::ostream& s, const FlatHeightfield& v); + + std::ostream& operator<<(std::ostream& s, const Heightfield& v); + + std::ostream& operator<<(std::ostream& s, CollisionShapeType v); + + std::ostream& operator<<(std::ostream& s, const AgentBounds& v); + + struct WriteDtStatus { - switch (v) - { - case CollisionShapeType::Aabb: return s << "AgentShapeType::Aabb"; - case CollisionShapeType::RotatingBox: return s << "AgentShapeType::RotatingBox"; - } - return s << "AgentShapeType::" << static_cast>(v); - } - - inline std::ostream& operator<<(std::ostream& s, const AgentBounds& v) + dtStatus mStatus; + }; + + std::ostream& operator<<(std::ostream& stream, const WriteDtStatus& value); + + std::ostream& operator<<(std::ostream& stream, const Flag value); + + struct WriteFlags { - return s << "AgentBounds {" << v.mShapeType << ", " << v.mHalfExtents << "}"; - } + Flags mValue; + }; + + std::ostream& operator<<(std::ostream& stream, const WriteFlags& value); + + std::ostream& operator<<(std::ostream& stream, AreaType value); + + std::ostream& operator<<(std::ostream& stream, ChangeType value); class RecastMesh; struct RecastSettings; diff --git a/components/detournavigator/dtstatus.hpp b/components/detournavigator/dtstatus.hpp deleted file mode 100644 index a73d33be1e..0000000000 --- a/components/detournavigator/dtstatus.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_DTSTATUS_H -#define OPENMW_COMPONENTS_DETOURNAVIGATOR_DTSTATUS_H - -#include - -#include -#include - -namespace DetourNavigator -{ - struct WriteDtStatus - { - dtStatus status; - }; - - static const std::vector> dtStatuses { - {DT_FAILURE, "DT_FAILURE"}, - {DT_SUCCESS, "DT_SUCCESS"}, - {DT_IN_PROGRESS, "DT_IN_PROGRESS"}, - {DT_WRONG_MAGIC, "DT_WRONG_MAGIC"}, - {DT_WRONG_VERSION, "DT_WRONG_VERSION"}, - {DT_OUT_OF_MEMORY, "DT_OUT_OF_MEMORY"}, - {DT_INVALID_PARAM, "DT_INVALID_PARAM"}, - {DT_BUFFER_TOO_SMALL, "DT_BUFFER_TOO_SMALL"}, - {DT_OUT_OF_NODES, "DT_OUT_OF_NODES"}, - {DT_PARTIAL_RESULT, "DT_PARTIAL_RESULT"}, - }; - - inline std::ostream& operator <<(std::ostream& stream, const WriteDtStatus& value) - { - for (const auto& status : dtStatuses) - if (value.status & status.first) - stream << status.second << " "; - return stream; - } -} - -#endif diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index fa35470c42..aade62ad62 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -1,12 +1,10 @@ #ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_FINDSMOOTHPATH_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_FINDSMOOTHPATH_H -#include "dtstatus.hpp" #include "exceptions.hpp" #include "flags.hpp" #include "settings.hpp" #include "settingsutils.hpp" -#include "debug.hpp" #include "status.hpp" #include "areatype.hpp" diff --git a/components/detournavigator/flags.hpp b/components/detournavigator/flags.hpp index 887fd42640..981895ca94 100644 --- a/components/detournavigator/flags.hpp +++ b/components/detournavigator/flags.hpp @@ -1,8 +1,6 @@ #ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H -#include - namespace DetourNavigator { using Flags = unsigned short; @@ -15,54 +13,6 @@ namespace DetourNavigator Flag_openDoor = 1 << 2, Flag_usePathgrid = 1 << 3, }; - - inline std::ostream& operator <<(std::ostream& stream, const Flag value) - { - switch (value) - { - case Flag_none: - return stream << "none"; - case Flag_walk: - return stream << "walk"; - case Flag_swim: - return stream << "swim"; - case Flag_openDoor: - return stream << "openDoor"; - case Flag_usePathgrid: - return stream << "usePathgrid"; - } - - return stream; - } - - struct WriteFlags - { - Flags mValue; - - friend inline std::ostream& operator <<(std::ostream& stream, const WriteFlags& value) - { - if (value.mValue == Flag_none) - { - return stream << Flag_none; - } - else - { - bool first = true; - for (const auto flag : {Flag_walk, Flag_swim, Flag_openDoor, Flag_usePathgrid}) - { - if (value.mValue & flag) - { - if (!first) - stream << " | "; - first = false; - stream << flag; - } - } - - return stream; - } - } - }; } #endif diff --git a/components/detournavigator/navmeshcacheitem.cpp b/components/detournavigator/navmeshcacheitem.cpp index ffcb0a7359..41a177a367 100644 --- a/components/detournavigator/navmeshcacheitem.cpp +++ b/components/detournavigator/navmeshcacheitem.cpp @@ -1,6 +1,5 @@ #include "tileposition.hpp" #include "navmeshtilescache.hpp" -#include "dtstatus.hpp" #include "navmeshtileview.hpp" #include "navmeshcacheitem.hpp" #include "navmeshdata.hpp" @@ -9,6 +8,8 @@ #include +#include + namespace { using DetourNavigator::TilePosition; @@ -35,6 +36,32 @@ namespace namespace DetourNavigator { + std::ostream& operator<<(std::ostream& stream, UpdateNavMeshStatus value) + { + switch (value) + { + case UpdateNavMeshStatus::ignored: + return stream << "ignore"; + case UpdateNavMeshStatus::removed: + return stream << "removed"; + case UpdateNavMeshStatus::added: + return stream << "add"; + case UpdateNavMeshStatus::replaced: + return stream << "replaced"; + case UpdateNavMeshStatus::failed: + return stream << "failed"; + case UpdateNavMeshStatus::lost: + return stream << "lost"; + case UpdateNavMeshStatus::cached: + return stream << "cached"; + case UpdateNavMeshStatus::unchanged: + return stream << "unchanged"; + case UpdateNavMeshStatus::restored: + return stream << "restored"; + } + return stream << "unknown(" << static_cast(value) << ")"; + } + const dtMeshTile* getTile(const dtNavMesh& navMesh, const TilePosition& position) { const int layer = 0; diff --git a/components/detournavigator/navmeshcacheitem.hpp b/components/detournavigator/navmeshcacheitem.hpp index ae4a2de66b..97ad68f1c7 100644 --- a/components/detournavigator/navmeshcacheitem.hpp +++ b/components/detournavigator/navmeshcacheitem.hpp @@ -4,14 +4,13 @@ #include "sharednavmesh.hpp" #include "tileposition.hpp" #include "navmeshtilescache.hpp" -#include "dtstatus.hpp" #include "navmeshdata.hpp" #include "version.hpp" #include #include -#include +#include #include struct dtMeshTile; @@ -36,31 +35,7 @@ namespace DetourNavigator return (static_cast(value) & static_cast(UpdateNavMeshStatus::failed)) == 0; } - inline std::ostream& operator <<(std::ostream& stream, UpdateNavMeshStatus value) - { - switch (value) - { - case UpdateNavMeshStatus::ignored: - return stream << "ignore"; - case UpdateNavMeshStatus::removed: - return stream << "removed"; - case UpdateNavMeshStatus::added: - return stream << "add"; - case UpdateNavMeshStatus::replaced: - return stream << "replaced"; - case UpdateNavMeshStatus::failed: - return stream << "failed"; - case UpdateNavMeshStatus::lost: - return stream << "lost"; - case UpdateNavMeshStatus::cached: - return stream << "cached"; - case UpdateNavMeshStatus::unchanged: - return stream << "unchanged"; - case UpdateNavMeshStatus::restored: - return stream << "restored"; - } - return stream << "unknown(" << static_cast(value) << ")"; - } + std::ostream& operator<<(std::ostream& stream, UpdateNavMeshStatus value); class UpdateNavMeshStatusBuilder { diff --git a/components/detournavigator/navmeshmanager.cpp b/components/detournavigator/navmeshmanager.cpp index ccab20a5aa..672741e089 100644 --- a/components/detournavigator/navmeshmanager.cpp +++ b/components/detournavigator/navmeshmanager.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include diff --git a/components/sceneutil/detourdebugdraw.cpp b/components/sceneutil/detourdebugdraw.cpp index f1325340ea..62e7ea71c0 100644 --- a/components/sceneutil/detourdebugdraw.cpp +++ b/components/sceneutil/detourdebugdraw.cpp @@ -1,16 +1,12 @@ #include "detourdebugdraw.hpp" #include "util.hpp" -#include - #include #include #include namespace { - using DetourNavigator::operator<<; - osg::PrimitiveSet::Mode toOsgPrimitiveSetMode(duDebugDrawPrimitives value) { switch (value)