All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AStarState.h
1 #pragma once
2 
3 #include "Graphs.h"
4 #include "TiledGraphNode.h"
5 #include "TiledGraphEdge.h"
6 
7 namespace Eegeo
8 {
9  namespace Graphs
10  {
11  struct AStarState
12  {
13  AStarState()
14  : m_prior(-1)
15  , m_costToTraverseEdge(0.f)
16  , m_f(0.f)
17  , m_g(0.f)
18  , m_h(0.f)
19  , m_closed(false)
20  {}
21 
22  AStarState(
23  const TiledGraphEdgeId& graphEdgeId,
24  int prior,
25  float costToTraverseEdge,
26  float f,
27  float g,
28  float h,
29  bool closed
30  )
31  : m_graphEdgeId(graphEdgeId)
32  , m_prior(prior)
33  , m_costToTraverseEdge(costToTraverseEdge)
34  , m_f(f)
35  , m_g(g)
36  , m_h(h)
37  , m_closed(closed)
38  {}
39 
40 
41  const TiledGraphEdgeId& GetGraphEdgeId() const { return m_graphEdgeId; }
42  const int Prior() const { return m_prior; }
43  float GetCostToTraverseEdge() const { return m_costToTraverseEdge; }
44  float F() const { return m_f; }
45  float G() const { return m_g; }
46  float H() const { return m_h; }
47  bool IsClosed() const { return m_closed; }
48 
49  void Close() { m_closed = true; }
50  void Update(int prior, float g)
51  {
52  m_prior = prior;
53  m_g = g;
54  m_f = m_g + m_h;
55  }
56 
57 
58  private:
59  TiledGraphEdgeId m_graphEdgeId;
60  int m_prior;
61  float m_costToTraverseEdge;
62  float m_f;
63  float m_g;
64  float m_h;
65  bool m_closed;
66  };
67 
68  }
69 }