diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index 3043c36308..c53fcdcc48 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -26,10 +26,10 @@ #include #include +namespace DetourNavigator +{ namespace { - using namespace DetourNavigator; - struct Rectangle { TileBounds mBounds; @@ -388,6 +388,7 @@ namespace return power; } } +} // namespace DetourNavigator namespace DetourNavigator { diff --git a/components/detournavigator/navmeshtileview.cpp b/components/detournavigator/navmeshtileview.cpp index 336cd1ba84..d12bcecd7e 100644 --- a/components/detournavigator/navmeshtileview.cpp +++ b/components/detournavigator/navmeshtileview.cpp @@ -9,14 +9,11 @@ #include #include -namespace +inline bool operator==(const dtMeshHeader& lhs, const dtMeshHeader& rhs) noexcept { - using DetourNavigator::ArrayRef; - using DetourNavigator::Ref; - using DetourNavigator::Span; - - auto makeTuple(const dtMeshHeader& v) + const auto makeTuple = [] (const dtMeshHeader& v) { + using DetourNavigator::ArrayRef; return std::tuple( v.x, v.y, @@ -39,47 +36,46 @@ namespace ArrayRef(v.bmax), v.bvQuantFactor ); - } + }; + return makeTuple(lhs) == makeTuple(rhs); +} - auto makeTuple(const dtPoly& v) +inline bool operator==(const dtPoly& lhs, const dtPoly& rhs) noexcept +{ + const auto makeTuple = [] (const dtPoly& v) { + using DetourNavigator::ArrayRef; return std::tuple(ArrayRef(v.verts), ArrayRef(v.neis), v.flags, v.vertCount, v.areaAndtype); - } + }; + return makeTuple(lhs) == makeTuple(rhs); +} - auto makeTuple(const dtPolyDetail& v) +inline bool operator==(const dtPolyDetail& lhs, const dtPolyDetail& rhs) noexcept +{ + const auto makeTuple = [] (const dtPolyDetail& v) { return std::tuple(v.vertBase, v.triBase, v.vertCount, v.triCount); - } + }; + return makeTuple(lhs) == makeTuple(rhs); +} - auto makeTuple(const dtBVNode& v) +inline bool operator==(const dtBVNode& lhs, const dtBVNode& rhs) noexcept +{ + const auto makeTuple = [] (const dtBVNode& v) { + using DetourNavigator::ArrayRef; return std::tuple(ArrayRef(v.bmin), ArrayRef(v.bmax), v.i); - } - - auto makeTuple(const dtOffMeshConnection& v) - { - return std::tuple(ArrayRef(v.pos), v.rad, v.poly, v.flags, v.side, v.userId); - } - - auto makeTuple(const DetourNavigator::NavMeshTileConstView& v) - { - return std::tuple( - Ref(*v.mHeader), - Span(v.mPolys, v.mHeader->polyCount), - Span(v.mVerts, v.mHeader->vertCount), - Span(v.mDetailMeshes, v.mHeader->detailMeshCount), - Span(v.mDetailVerts, v.mHeader->detailVertCount), - Span(v.mDetailTris, v.mHeader->detailTriCount), - Span(v.mBvTree, v.mHeader->bvNodeCount), - Span(v.mOffMeshCons, v.mHeader->offMeshConCount) - ); - } + }; + return makeTuple(lhs) == makeTuple(rhs); } -template -inline auto operator==(const T& lhs, const T& rhs) - -> std::enable_if_t, void>, bool> +inline bool operator==(const dtOffMeshConnection& lhs, const dtOffMeshConnection& rhs) noexcept { + const auto makeTuple = [] (const dtOffMeshConnection& v) + { + using DetourNavigator::ArrayRef; + return std::tuple(ArrayRef(v.pos), v.rad, v.poly, v.flags, v.side, v.userId); + }; return makeTuple(lhs) == makeTuple(rhs); } @@ -139,8 +135,23 @@ namespace DetourNavigator return view; } - bool operator==(const NavMeshTileConstView& lhs, const NavMeshTileConstView& rhs) + bool operator==(const NavMeshTileConstView& lhs, const NavMeshTileConstView& rhs) noexcept { + using DetourNavigator::Ref; + using DetourNavigator::Span; + const auto makeTuple = [] (const DetourNavigator::NavMeshTileConstView& v) + { + return std::tuple( + Ref(*v.mHeader), + Span(v.mPolys, v.mHeader->polyCount), + Span(v.mVerts, v.mHeader->vertCount), + Span(v.mDetailMeshes, v.mHeader->detailMeshCount), + Span(v.mDetailVerts, v.mHeader->detailVertCount), + Span(v.mDetailTris, v.mHeader->detailTriCount), + Span(v.mBvTree, v.mHeader->bvNodeCount), + Span(v.mOffMeshCons, v.mHeader->offMeshConCount) + ); + }; return makeTuple(lhs) == makeTuple(rhs); } } diff --git a/components/detournavigator/navmeshtileview.hpp b/components/detournavigator/navmeshtileview.hpp index 92017360c3..b797545b8a 100644 --- a/components/detournavigator/navmeshtileview.hpp +++ b/components/detournavigator/navmeshtileview.hpp @@ -21,7 +21,7 @@ namespace DetourNavigator const dtBVNode* mBvTree; const dtOffMeshConnection* mOffMeshCons; - friend bool operator==(const NavMeshTileConstView& lhs, const NavMeshTileConstView& rhs); + friend bool operator==(const NavMeshTileConstView& lhs, const NavMeshTileConstView& rhs) noexcept; }; NavMeshTileConstView asNavMeshTileConstView(const unsigned char* data); diff --git a/components/detournavigator/preparednavmeshdata.cpp b/components/detournavigator/preparednavmeshdata.cpp index 3fea46b26c..c86e18482c 100644 --- a/components/detournavigator/preparednavmeshdata.cpp +++ b/components/detournavigator/preparednavmeshdata.cpp @@ -6,8 +6,6 @@ namespace { - using namespace DetourNavigator; - void initPolyMeshDetail(rcPolyMeshDetail& value) noexcept { value.meshes = nullptr; @@ -26,13 +24,6 @@ namespace } } -template -inline constexpr auto operator==(const T& lhs, const T& rhs) noexcept - -> std::enable_if_t, void>, bool> -{ - return makeTuple(lhs) == makeTuple(rhs); -} - namespace DetourNavigator { PreparedNavMeshData::PreparedNavMeshData() noexcept diff --git a/components/detournavigator/preparednavmeshdatatuple.hpp b/components/detournavigator/preparednavmeshdatatuple.hpp index bcca0ace37..03b192ad38 100644 --- a/components/detournavigator/preparednavmeshdatatuple.hpp +++ b/components/detournavigator/preparednavmeshdatatuple.hpp @@ -9,10 +9,11 @@ #include -namespace DetourNavigator +inline bool operator==(const rcPolyMesh& lhs, const rcPolyMesh& rhs) noexcept { - constexpr auto makeTuple(const rcPolyMesh& v) noexcept + const auto makeTuple = [] (const rcPolyMesh& v) { + using namespace DetourNavigator; return std::tuple( Span(v.verts, static_cast(getVertsLength(v))), Span(v.polys, static_cast(getPolysLength(v))), @@ -26,18 +27,27 @@ namespace DetourNavigator v.borderSize, v.maxEdgeError ); - } + }; + return makeTuple(lhs) == makeTuple(rhs); +} - constexpr auto makeTuple(const rcPolyMeshDetail& v) noexcept +inline bool operator==(const rcPolyMeshDetail& lhs, const rcPolyMeshDetail& rhs) noexcept +{ + const auto makeTuple = [] (const rcPolyMeshDetail& v) { + using namespace DetourNavigator; return std::tuple( Span(v.meshes, static_cast(getMeshesLength(v))), Span(v.verts, static_cast(getVertsLength(v))), Span(v.tris, static_cast(getTrisLength(v))) ); - } + }; + return makeTuple(lhs) == makeTuple(rhs); +} - constexpr auto makeTuple(const PreparedNavMeshData& v) noexcept +namespace DetourNavigator +{ + inline auto makeTuple(const PreparedNavMeshData& v) noexcept { return std::tuple( v.mUserId,