1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +00:00
OpenMW/apps/openmw/mwmechanics/pathgrid.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
2.0 KiB
C++
Raw Normal View History

#ifndef GAME_MWMECHANICS_PATHGRID_H
#define GAME_MWMECHANICS_PATHGRID_H
2018-08-19 00:28:11 +03:00
#include <deque>
#include <components/esm3/loadpgrd.hpp>
2016-06-17 23:07:16 +09:00
namespace MWMechanics
{
class PathgridGraph
{
PathgridGraph()
: mPathgrid(nullptr)
{
}
2022-09-22 21:26:05 +03:00
public:
explicit PathgridGraph(const ESM::Pathgrid& pathGrid);
2022-09-22 21:26:05 +03:00
const ESM::Pathgrid* getPathgrid() const { return mPathgrid; }
2022-09-22 21:26:05 +03:00
// returns true if end point is strongly connected (i.e. reachable
// from start point) both start and end are pathgrid point indexes
bool isPointConnected(const size_t start, const size_t end) const;
2022-09-22 21:26:05 +03:00
// get neighbouring nodes for index node and put them to "nodes" vector
void getNeighbouringPoints(const size_t index, ESM::Pathgrid::PointList& nodes) const;
2022-09-22 21:26:05 +03:00
2014-04-04 18:17:42 +11:00
// the input parameters are pathgrid point indexes
// the output list is in local (internal cells) or world (external
2016-12-14 22:11:22 +01:00
// cells) coordinates
2014-04-20 08:31:02 +10:00
//
// NOTE: if start equals end an empty path is returned
std::deque<ESM::Pathgrid::Point> aStarSearch(const size_t start, const size_t end) const;
static const PathgridGraph sEmpty;
2022-09-22 21:26:05 +03:00
private:
const ESM::Pathgrid* mPathgrid;
2022-09-22 21:26:05 +03:00
class Builder;
struct ConnectedPoint // edge
{
size_t index; // pathgrid point index of neighbour
float cost;
};
2022-09-22 21:26:05 +03:00
struct Node // point
{
int componentId;
std::vector<ConnectedPoint> edges; // neighbours
};
2022-09-22 21:26:05 +03:00
// componentId is an integer indicating the groups of connected
// pathgrid points (all connected points will have the same value)
//
// In Seyda Neen there are 3:
//
// 52, 53 and 54 are one set (enclosed yard)
// 48, 49, 50, 51, 84, 85, 86, 87, 88, 89, 90 (ship & office)
// all other pathgrid points are the third set
//
std::vector<Node> mGraph;
};
}
#endif