mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
|
#ifndef GAME_MWMECHANICS_PATHGRID_H
|
||
|
#define GAME_MWMECHANICS_PATHGRID_H
|
||
|
|
||
|
#include <components/esm/loadpgrd.hpp>
|
||
|
#include <list>
|
||
|
|
||
|
namespace ESM
|
||
|
{
|
||
|
class Cell;
|
||
|
}
|
||
|
|
||
|
namespace MWWorld
|
||
|
{
|
||
|
class CellStore;
|
||
|
}
|
||
|
|
||
|
namespace MWMechanics
|
||
|
{
|
||
|
class PathgridGraph
|
||
|
{
|
||
|
public:
|
||
|
PathgridGraph();
|
||
|
|
||
|
bool load(const ESM::Cell *cell);
|
||
|
|
||
|
// 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 int start, const int end) const;
|
||
|
|
||
|
// isOutside is used whether to convert path to world co-ordinates
|
||
|
std::list<ESM::Pathgrid::Point> aStarSearch(const int start,
|
||
|
const int end,
|
||
|
const bool isOutside) const;
|
||
|
private:
|
||
|
|
||
|
const ESM::Cell *mCell;
|
||
|
const ESM::Pathgrid *mPathgrid;
|
||
|
|
||
|
struct ConnectedPoint // edge
|
||
|
{
|
||
|
int index; // pathgrid point index of neighbour
|
||
|
float cost;
|
||
|
};
|
||
|
|
||
|
struct Node // point
|
||
|
{
|
||
|
int componentId;
|
||
|
std::vector<ConnectedPoint> edges; // neighbours
|
||
|
};
|
||
|
|
||
|
// 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;
|
||
|
bool mIsGraphConstructed;
|
||
|
|
||
|
// variables used to calculate connected components
|
||
|
int mSCCId;
|
||
|
int mSCCIndex;
|
||
|
std::vector<int> mSCCStack;
|
||
|
typedef std::pair<int, int> VPair; // first is index, second is lowlink
|
||
|
std::vector<VPair> mSCCPoint;
|
||
|
// methods used to calculate connected components
|
||
|
void recursiveStrongConnect(int v);
|
||
|
void buildConnectedPoints();
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif
|