From 5f5163905abb8c74876fd2f7f93c1d462f4bbff6 Mon Sep 17 00:00:00 2001 From: elsid <elsid.mail@gmail.com> Date: Fri, 5 Nov 2021 14:14:15 +0100 Subject: [PATCH 1/4] Remove unused operator< for RecastMesh --- components/detournavigator/recastmesh.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/detournavigator/recastmesh.hpp b/components/detournavigator/recastmesh.hpp index c8e160603b..e2e7b9e188 100644 --- a/components/detournavigator/recastmesh.hpp +++ b/components/detournavigator/recastmesh.hpp @@ -132,11 +132,6 @@ namespace DetourNavigator std::vector<FlatHeightfield> mFlatHeightfields; Bounds mBounds; - friend inline bool operator <(const RecastMesh& lhs, const RecastMesh& rhs) noexcept - { - return std::tie(lhs.mMesh, lhs.mWater) < std::tie(rhs.mMesh, rhs.mWater); - } - friend inline std::size_t getSize(const RecastMesh& value) noexcept { return getSize(value.mMesh) + value.mWater.size() * sizeof(Cell) From 671e1e542402d104a128bff1309f117dfa43dee8 Mon Sep 17 00:00:00 2001 From: elsid <elsid.mail@gmail.com> Date: Fri, 5 Nov 2021 17:36:53 +0100 Subject: [PATCH 2/4] Avoid copy when adding heightfield to vector --- components/detournavigator/recastmeshbuilder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/detournavigator/recastmeshbuilder.cpp b/components/detournavigator/recastmeshbuilder.cpp index 8f860d2eb1..ae3458a011 100644 --- a/components/detournavigator/recastmeshbuilder.cpp +++ b/components/detournavigator/recastmeshbuilder.cpp @@ -242,7 +242,7 @@ namespace DetourNavigator heightfield.mShift = shift + osg::Vec3f(minX, minY, 0) * stepSize - osg::Vec3f(halfCellSize, halfCellSize, 0); heightfield.mScale = stepSize; heightfield.mHeights = std::move(tileHeights); - mHeightfields.emplace_back(heightfield); + mHeightfields.push_back(std::move(heightfield)); } std::shared_ptr<RecastMesh> RecastMeshBuilder::create(std::size_t generation, std::size_t revision) && From 5972520b1abb4ffa971c930e4c8861ecd990d69d Mon Sep 17 00:00:00 2001 From: elsid <elsid.mail@gmail.com> Date: Fri, 5 Nov 2021 17:52:37 +0100 Subject: [PATCH 3/4] Make sure areas size is 2 for rectangle --- components/detournavigator/makenavmesh.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index 3f133f5033..3043c36308 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -198,7 +198,7 @@ namespace } bool rasterizeTriangles(rcContext& context, const Rectangle& rectangle, const rcConfig& config, - const unsigned char* areas, std::size_t areasSize, rcHeightfield& solid) + AreaType areaType, rcHeightfield& solid) { const osg::Vec2f tileBoundsMin( std::clamp(rectangle.mBounds.mMin.x(), config.bmin[0], config.bmax[0]), @@ -224,13 +224,15 @@ namespace 0, 2, 3, }; + const std::array<unsigned char, 2> areas {areaType, areaType}; + return rcRasterizeTriangles( &context, vertices.data(), static_cast<int>(vertices.size() / 3), indices.data(), - areas, - static_cast<int>(areasSize), + areas.data(), + static_cast<int>(areas.size()), solid, config.walkableClimb ); @@ -239,11 +241,10 @@ namespace bool rasterizeTriangles(rcContext& context, const osg::Vec3f& agentHalfExtents, const std::vector<Cell>& cells, const Settings& settings, const rcConfig& config, rcHeightfield& solid) { - const std::array<unsigned char, 2> areas {{AreaType_water, AreaType_water}}; for (const Cell& cell : cells) { const Rectangle rectangle = getSwimRectangle(cell, settings, agentHalfExtents); - if (!rasterizeTriangles(context, rectangle, config, areas.data(), areas.size(), solid)) + if (!rasterizeTriangles(context, rectangle, config, AreaType_water, solid)) return false; } return true; @@ -254,9 +255,8 @@ namespace { for (const FlatHeightfield& heightfield : heightfields) { - const std::array<unsigned char, 2> areas {{AreaType_ground, AreaType_ground}}; const Rectangle rectangle {heightfield.mBounds, toNavMeshCoordinates(settings, heightfield.mHeight)}; - if (!rasterizeTriangles(context, rectangle, config, areas.data(), areas.size(), solid)) + if (!rasterizeTriangles(context, rectangle, config, AreaType_ground, solid)) return false; } return true; From 3b6184dcdac631ba3ccd234f7db2e827617e9c2b Mon Sep 17 00:00:00 2001 From: elsid <elsid.mail@gmail.com> Date: Tue, 9 Nov 2021 12:32:25 +0100 Subject: [PATCH 4/4] Add missing include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.cpp:1:0: /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.hpp:93:48: error: field ‘mSettings’ has incomplete type ‘std::reference_wrapper<const DetourNavigator::Settings>’ std::reference_wrapper<const Settings> mSettings; ^~~~~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/istream:38, from /usr/include/c++/7/sstream:38, from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/dtstatus.hpp:6, from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.hpp:4, from /<<BUILDDIR>>/openmw-0.47.0+git202111080927~ubuntu18.04.1/components/detournavigator/findsmoothpath.cpp:1: /usr/include/c++/7/type_traits:2125:11: note: declaration of ‘class std::reference_wrapper<const DetourNavigator::Settings>’ class reference_wrapper; --- components/detournavigator/findsmoothpath.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/detournavigator/findsmoothpath.hpp b/components/detournavigator/findsmoothpath.hpp index 07d3054e19..2e63340578 100644 --- a/components/detournavigator/findsmoothpath.hpp +++ b/components/detournavigator/findsmoothpath.hpp @@ -18,6 +18,7 @@ #include <cassert> #include <vector> +#include <functional> class dtNavMesh;