All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
TiledGraphPathfinder.h
1 #pragma once
2 
3 #include "Graphs.h"
4 #include "Types.h"
5 #include "TiledGraphPathfinderResult.h"
6 #include "AStarPriorityQueue.h"
7 #include "AStarState.h"
8 #include "TiledGraphEdge.h"
9 #include "VectorMath.h"
10 
11 #include <vector>
12 #include <unordered_map>
13 
14 
15 namespace Eegeo
16 {
17  namespace Graphs
18  {
20  {
21  public:
23  const TiledGraph& tiledGraph
24  );
25 
26  TiledGraphPathfinderResult FindShortestPath(
27  const TiledGraphEdgeId& graphEdgeA,
28  const float parameterisedPointOnEdgeA,
29  bool allowUTurnAtA,
30  const TiledGraphEdgeId& graphEdgeB,
31  const float parameterisedPointOnEdgeB,
32  bool allowUTurnAtB);
33 
34  private:
35  typedef std::unordered_map<TiledGraphEdgeId, int, TiledGraphEdgeIdHash> TGraphEdgeIdToAStarState;
36 
37  TiledGraphPathfinderResult FindShortestPathInternal(
38  const TiledGraphEdgeId& graphEdgeA,
39  const float parameterisedPointOnEdgeA,
40  const TiledGraphEdgeId& graphEdgeB,
41  const float parameterisedPointOnEdgeB,
42  const float maxCost);
43 
44  bool ValidateInput(
45  const TiledGraphEdgeId& graphEdgeA,
46  const float parameterisedPointOnEdgeA,
47  const TiledGraphEdgeId& graphEdgeB,
48  const float parameterisedPointOnEdgeB) const;
49 
50  void OpenEdge(const TiledGraphEdgeId& graphEdgeId, int priorStateIndex, const float costToPrior, const float costToTraverseEdge, const float h);
51  void CloseEdge(const TiledGraphEdgeId& graphEdgeId);
52  void OpenNeighbours(const TiledGraphEdgeId& graphNodeId);
53 
54  float Heuristic(const TiledGraphEdge& edge) const;
55  float Distance(const dv3& a, const dv3& b) const;
56  std::vector<TiledGraphEdgeId> ReconstructPathEdges() const;
57  TiledGraphPathfinderResult BuildResult(bool succeeded) const;
58  void Clear();
59 
60 
61  const TiledGraph& m_tiledGraph;
62  AStarStatePriorityComparer m_comparer;
63  AStarPriorityQueue m_prioritisedOpenEdges;
64  TGraphEdgeIdToAStarState m_graphEdgeIdToState;
65  std::vector<AStarState> m_stateVector;
66 
67  std::vector<TiledGraphEdgeId> m_edgeIdsScratch;
68 
69  TiledGraphEdgeId m_startGraphEdgeId;
70  float m_startParameterisedPointOnEdge;
71  TiledGraphEdgeId m_goalGraphEdgeId;
72  float m_goalParameterisedPointOnEdge;
73  dv3 m_goalPoint;
74  float m_maxCost;
75 
76  };
77  }
78 }