1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Use std::span for makeSmoothPath polygonPath

This commit is contained in:
elsid 2023-06-18 19:46:33 +02:00
parent 53a129a762
commit c334176d73
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
2 changed files with 6 additions and 4 deletions

View File

@ -9,7 +9,7 @@
namespace DetourNavigator
{
std::size_t fixupCorridor(std::vector<dtPolyRef>& path, std::size_t pathSize, const std::vector<dtPolyRef>& visited)
std::size_t fixupCorridor(std::span<dtPolyRef> path, std::size_t pathSize, const std::vector<dtPolyRef>& visited)
{
std::vector<dtPolyRef>::const_reverse_iterator furthestVisited;

View File

@ -14,6 +14,7 @@
#include <cassert>
#include <functional>
#include <span>
#include <vector>
namespace DetourNavigator
@ -23,8 +24,7 @@ namespace DetourNavigator
return (osg::Vec2f(v1.x(), v1.z()) - osg::Vec2f(v2.x(), v2.z())).length() < r;
}
std::size_t fixupCorridor(
std::vector<dtPolyRef>& path, std::size_t pathSize, const std::vector<dtPolyRef>& visited);
std::size_t fixupCorridor(std::span<dtPolyRef> path, std::size_t pathSize, const std::vector<dtPolyRef>& visited);
// This function checks if the path has a small U-turn, that is,
// a polygon further in the path is adjacent to the first polygon
@ -127,9 +127,11 @@ namespace DetourNavigator
template <class OutputIterator>
Status makeSmoothPath(const dtNavMeshQuery& navMeshQuery, const dtQueryFilter& filter, const osg::Vec3f& start,
const osg::Vec3f& end, const float stepSize, std::vector<dtPolyRef>& polygonPath, std::size_t polygonPathSize,
const osg::Vec3f& end, const float stepSize, std::span<dtPolyRef> polygonPath, std::size_t polygonPathSize,
std::size_t maxSmoothPathSize, OutputIterator& out)
{
assert(polygonPathSize <= polygonPath.size());
// Iterate over the path to find smooth path on the detail mesh surface.
osg::Vec3f iterPos;
navMeshQuery.closestPointOnPoly(polygonPath.front(), start.ptr(), iterPos.ptr(), nullptr);