OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pathgrid.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_PATHGRID_H
2 #define GAME_MWMECHANICS_PATHGRID_H
3 
4 #include <list>
5 
7 
8 namespace ESM
9 {
10  struct Cell;
11 }
12 
13 namespace MWWorld
14 {
15  class CellStore;
16 }
17 
18 namespace MWMechanics
19 {
21  {
22  public:
23  PathgridGraph();
24 
25  bool load(const MWWorld::CellStore *cell);
26 
27  // returns true if end point is strongly connected (i.e. reachable
28  // from start point) both start and end are pathgrid point indexes
29  bool isPointConnected(const int start, const int end) const;
30 
31  // the input parameters are pathgrid point indexes
32  // the output list is in local (internal cells) or world (external
33  // cells) coordinates
34  //
35  // NOTE: if start equals end an empty path is returned
36  std::list<ESM::Pathgrid::Point> aStarSearch(const int start,
37  const int end) const;
38  private:
39 
40  const ESM::Cell *mCell;
43 
44  struct ConnectedPoint // edge
45  {
46  int index; // pathgrid point index of neighbour
47  float cost;
48  };
49 
50  struct Node // point
51  {
53  std::vector<ConnectedPoint> edges; // neighbours
54  };
55 
56  // componentId is an integer indicating the groups of connected
57  // pathgrid points (all connected points will have the same value)
58  //
59  // In Seyda Neen there are 3:
60  //
61  // 52, 53 and 54 are one set (enclosed yard)
62  // 48, 49, 50, 51, 84, 85, 86, 87, 88, 89, 90 (ship & office)
63  // all other pathgrid points are the third set
64  //
65  std::vector<Node> mGraph;
67 
68  // variables used to calculate connected components
69  int mSCCId;
70  int mSCCIndex;
71  std::vector<int> mSCCStack;
72  typedef std::pair<int, int> VPair; // first is index, second is lowlink
73  std::vector<VPair> mSCCPoint;
74  // methods used to calculate connected components
75  void recursiveStrongConnect(int v);
76  void buildConnectedPoints();
77  };
78 }
79 
80 #endif
std::pair< int, int > VPair
Definition: pathgrid.hpp:72
Definition: pathgrid.hpp:50
int mSCCId
Definition: pathgrid.hpp:69
std::vector< int > mSCCStack
Definition: pathgrid.hpp:71
void buildConnectedPoints()
Definition: pathgrid.cpp:196
bool mIsExterior
Definition: pathgrid.hpp:42
int mSCCIndex
Definition: pathgrid.hpp:70
std::vector< Node > mGraph
Definition: pathgrid.hpp:65
void recursiveStrongConnect(int v)
Definition: pathgrid.cpp:134
int index
Definition: pathgrid.hpp:46
std::list< ESM::Pathgrid::Point > aStarSearch(const int start, const int end) const
Definition: pathgrid.cpp:244
Mutable state of a cell.
Definition: cellstore.hpp:53
std::vector< VPair > mSCCPoint
Definition: pathgrid.hpp:73
std::vector< ConnectedPoint > edges
Definition: pathgrid.hpp:53
Definition: loadpgrd.hpp:16
Definition: loadcell.hpp:64
const ESM::Cell * mCell
Definition: pathgrid.hpp:40
Definition: pathgrid.hpp:20
float cost
Definition: pathgrid.hpp:47
const ESM::Pathgrid * mPathgrid
Definition: pathgrid.hpp:41
bool isPointConnected(const int start, const int end) const
Definition: pathgrid.cpp:212
bool mIsGraphConstructed
Definition: pathgrid.hpp:66
bool load(const MWWorld::CellStore *cell)
Definition: pathgrid.cpp:99
PathgridGraph()
Definition: pathgrid.cpp:52
int componentId
Definition: pathgrid.hpp:52