Store path points in deque

pull/541/head
elsid 6 years ago
parent 925d909fea
commit 9b3756f8bc
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -148,8 +148,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, const osg::Vec3f&
if (destInLOS && mPathFinder.getPath().size() > 1)
{
// get point just before dest
auto pPointBeforeDest = mPathFinder.getPath().rbegin();
++pPointBeforeDest;
auto pPointBeforeDest = mPathFinder.getPath().rbegin() + 1;
// if start point is closer to the target then last point of path (excluding target itself) then go straight on the target
if (distance(start, dest) <= distance(dest, *pPointBeforeDest))

@ -298,8 +298,7 @@ namespace MWMechanics
{
// if 2nd waypoint of new path == 1st waypoint of old,
// delete 1st waypoint of new path.
const auto iter = ++mPath.begin();
if (*iter == oldStart)
if (mPath[1] == oldStart)
{
mPath.pop_front();
}

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_PATHFINDING_H
#define GAME_MWMECHANICS_PATHFINDING_H
#include <list>
#include <deque>
#include <cassert>
#include <components/esm/defs.hpp>
@ -95,7 +95,7 @@ namespace MWMechanics
return mPath.size();
}
const std::list<osg::Vec3f>& getPath() const
const std::deque<osg::Vec3f>& getPath() const
{
return mPath;
}
@ -172,7 +172,7 @@ namespace MWMechanics
}
private:
std::list<osg::Vec3f> mPath;
std::deque<osg::Vec3f> mPath;
const ESM::Pathgrid *mPathgrid;
const MWWorld::CellStore* mCell;

Loading…
Cancel
Save