2013-03-31 17:30:03 +00:00
|
|
|
#ifndef GAME_MWMECHANICS_PATHFINDING_H
|
|
|
|
#define GAME_MWMECHANICS_PATHFINDING_H
|
|
|
|
|
|
|
|
#include <components/esm/loadpgrd.hpp>
|
|
|
|
#include <list>
|
2014-01-12 18:42:31 +01:00
|
|
|
#include <boost/graph/adjacency_list.hpp>
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class CellStore;
|
|
|
|
}
|
2013-03-31 17:30:03 +00:00
|
|
|
|
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
class PathFinder
|
|
|
|
{
|
2013-05-29 15:59:23 -07:00
|
|
|
public:
|
|
|
|
PathFinder();
|
2013-03-31 17:30:03 +00:00
|
|
|
|
2013-05-29 15:59:23 -07:00
|
|
|
void clearPath();
|
2014-01-12 18:42:31 +01:00
|
|
|
|
|
|
|
void buildPathgridGraph(const ESM::Pathgrid* pathGrid,float xCell = 0, float yCell = 0);
|
|
|
|
|
2013-08-29 19:17:27 -07:00
|
|
|
void buildPath(const ESM::Pathgrid::Point &startPoint, const ESM::Pathgrid::Point &endPoint,
|
2014-01-12 18:42:31 +01:00
|
|
|
const MWWorld::CellStore* cell, bool allowShortcuts = true);
|
2013-03-31 17:30:03 +00:00
|
|
|
|
2013-05-29 20:05:17 -07:00
|
|
|
bool checkPathCompleted(float x, float y, float z);
|
2013-05-29 17:33:33 -07:00
|
|
|
///< \Returns true if the last point of the path has been reached.
|
2013-10-07 10:20:02 +02:00
|
|
|
bool checkWaypoint(float x, float y, float z);
|
|
|
|
///< \Returns true if a way point was reached
|
2013-08-29 19:17:27 -07:00
|
|
|
float getZAngleToNext(float x, float y) const;
|
2013-03-31 17:30:03 +00:00
|
|
|
|
2013-08-29 19:17:27 -07:00
|
|
|
bool isPathConstructed() const
|
|
|
|
{
|
|
|
|
return mIsPathConstructed;
|
|
|
|
}
|
2013-03-31 17:30:03 +00:00
|
|
|
|
2013-10-07 10:20:02 +02:00
|
|
|
int getPathSize() const
|
|
|
|
{
|
|
|
|
return mPath.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::list<ESM::Pathgrid::Point> getPath() const
|
|
|
|
{
|
|
|
|
return mPath;
|
|
|
|
}
|
|
|
|
|
2014-01-07 21:10:57 +01:00
|
|
|
void addPointToPath(ESM::Pathgrid::Point &point)
|
|
|
|
{
|
|
|
|
mPath.push_back(point);
|
|
|
|
}
|
|
|
|
|
2013-05-29 15:59:23 -07:00
|
|
|
private:
|
|
|
|
std::list<ESM::Pathgrid::Point> mPath;
|
|
|
|
bool mIsPathConstructed;
|
2014-01-12 18:42:31 +01:00
|
|
|
|
|
|
|
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS,
|
|
|
|
boost::property<boost::vertex_index_t, int, ESM::Pathgrid::Point>, boost::property<boost::edge_weight_t, float> >
|
|
|
|
PathGridGraph;
|
|
|
|
PathGridGraph mGraph;
|
|
|
|
bool mIsGraphConstructed;
|
|
|
|
const MWWorld::CellStore* mCell;
|
2013-03-31 17:30:03 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-05-29 15:59:23 -07:00
|
|
|
#endif
|