gwnavruntime/abstractgraph/abstractgraph.h Source File

abstractgraph.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 #ifndef Navigation_AbstractGraph_H
8 #define Navigation_AbstractGraph_H
9 
17 
18 
19 
20 
21 namespace Kaim
22 {
23 
24 class AbstractGraphCellGrid;
25 class AbstractGraphBlob;
26 class AbstractGraph;
27 class Database;
28 class ScopedDisplayList;
29 class VisualColor;
30 class MemoryHeap;
31 
32 
33 class AbstractGraphNodeLink
34 {
35 public:
36  enum NavMeshLinkStatus
37  {
38  NavMeshLink_NoNavMesh = 0, // No Navmesh is loaded underneath, i.e. no ActiveCell at the CellPos of the node
39  NavMeshLink_Inside = 1, // A NavMesh is loaded, and the Node is on the NavMesh
40 
41  NavMeshLink_Undefined = KyUInt32MAXVAL, // Link Status is undefined yet
42  };
43 
44 public:
45  AbstractGraphNodeLink()
46  : m_navMeshLinkStatus(NavMeshLink_Undefined)
47  {}
48 
49  bool CanTraverse() const { return m_pairedNodeIdx.IsValid(); }
50 
51 public:
52  LoadedAbstractGraphNodeIdx m_pairedNodeIdx; //< gives the node in a neighbor graph, this node is paired to
53  NavMeshLinkStatus m_navMeshLinkStatus;
54 };
55 
56 
57 class AbstractGraph
58 {
59  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
60  KY_CLASS_WITHOUT_COPY(AbstractGraph)
61  KY_REFCOUNT_MALLOC_FREE(AbstractGraph)
62 
63 public:
64  static Ptr<AbstractGraph> Create(AbstractGraphBlob* abstractGraphBlob, Database* database, MemoryHeap* pheap = KY_NULL);
65 
66  KyUInt32 GetNodeCount() const { return m_blob->GetNodeCount(); }
67 
68  Vec3f GetNodePosition(const LoadedAbstractGraphNodeIdx& node) const;
69  Vec3f GetNodePosition(AbstractGraphNodeIdx nodeIdx) const;
70 
71  // -------------------- Access to Neighbors Nodes ------------------
72 
73  KyFloat32 GetNeighborCost(AbstractGraphNodeIdx fromGraphNodeIdx, AbstractGraphNodeIdx toGraphNodeIdx) const;
74 
75  const AbstractGraphCellBlob* GetAbstractGraphCellBlob(const LoadedAbstractGraphCellIdx cellIdx) const;
76  AbstractGraphCellGrid* GetAbstractGraphCellGrid() const;
77  Database* GetDatabase() const;
78 
79 public: // internal
80  KyUInt32 GetIndexInCollection() const { return m_abstractGraphIdx; }
81  void SetIndexInCollection(KyUInt32 indexInCollection);
82 
83  bool IsNodePaired(const LoadedAbstractGraphNodeIdx& node) const;
84  bool IsNodePaired(AbstractGraphNodeIdx nodeIdx) const;
85 
86  // Debug-only, used in unittests, not needed otherwise, the VisualDebug uses Blobs instead of ScopedDisplayLists
87  enum DebugDisplay
88  {
89  DebugDisplay_AbstractEdges = 1 << 0,
90  DebugDisplay_CellBoxCoverage = 1 << 1,
91  DebugDisplay_All = KyUInt32MAXVAL
92  };
93  void Display(ScopedDisplayList& displayList, const VisualColor& color, DebugDisplay debugDisplay = DebugDisplay_All);
94 
95 public:
96  Database* m_database;
97  const AbstractGraphBlob* m_blob;
98  AbstractGraphNodeLink* m_links; // for each graph nodes gives link information about the node in the neighbor AbstractGraph, and the Navmesh
99  AbstractGraphIdx m_abstractGraphIdx;
100 };
101 
102 }
103 
104 #endif
#define KY_REFCOUNT_MALLOC_FREE(ClassName)
Specific to RefCounting, no inheritance involved, used to make RefCount-able classes compatible with ...
Definition: memory.h:145
#define KY_NULL
Null value.
Definition: types.h:247
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43