mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-21 22:41:35 +00:00
Use std::span for makeSmoothPath polygonPath
This commit is contained in:
parent
53a129a762
commit
c334176d73
2 changed files with 6 additions and 4 deletions
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace DetourNavigator
|
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;
|
std::vector<dtPolyRef>::const_reverse_iterator furthestVisited;
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace DetourNavigator
|
namespace DetourNavigator
|
||||||
|
@ -23,8 +24,7 @@ namespace DetourNavigator
|
||||||
return (osg::Vec2f(v1.x(), v1.z()) - osg::Vec2f(v2.x(), v2.z())).length() < r;
|
return (osg::Vec2f(v1.x(), v1.z()) - osg::Vec2f(v2.x(), v2.z())).length() < r;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t fixupCorridor(
|
std::size_t fixupCorridor(std::span<dtPolyRef> path, std::size_t pathSize, const std::vector<dtPolyRef>& visited);
|
||||||
std::vector<dtPolyRef>& path, std::size_t pathSize, const std::vector<dtPolyRef>& visited);
|
|
||||||
|
|
||||||
// This function checks if the path has a small U-turn, that is,
|
// 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
|
// a polygon further in the path is adjacent to the first polygon
|
||||||
|
@ -127,9 +127,11 @@ namespace DetourNavigator
|
||||||
|
|
||||||
template <class OutputIterator>
|
template <class OutputIterator>
|
||||||
Status makeSmoothPath(const dtNavMeshQuery& navMeshQuery, const dtQueryFilter& filter, const osg::Vec3f& start,
|
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)
|
std::size_t maxSmoothPathSize, OutputIterator& out)
|
||||||
{
|
{
|
||||||
|
assert(polygonPathSize <= polygonPath.size());
|
||||||
|
|
||||||
// Iterate over the path to find smooth path on the detail mesh surface.
|
// Iterate over the path to find smooth path on the detail mesh surface.
|
||||||
osg::Vec3f iterPos;
|
osg::Vec3f iterPos;
|
||||||
navMeshQuery.closestPointOnPoly(polygonPath.front(), start.ptr(), iterPos.ptr(), nullptr);
|
navMeshQuery.closestPointOnPoly(polygonPath.front(), start.ptr(), iterPos.ptr(), nullptr);
|
||||||
|
|
Loading…
Reference in a new issue