gwnavruntime/abstractgraph/abstractgraph.h Source File

abstractgraph.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
9 //#include "gwnavruntime/abstractgraph/blobs/abstractgraphblob.h"
16 
17 namespace Kaim
18 {
19 
20 class AbstractGraphCellGrid;
21 class AbstractGraphBlob;
22 class AbstractGraphCellBlob;
23 class AbstractGraph;
24 class Database;
25 class DisplayList;
26 class Color;
27 class MemoryHeap;
28 class LoadedAbstractGraphCellIdx;
29 
30 class AbstractGraphNodeLink
31 {
32 public:
33  enum NavMeshLinkStatus
34  {
35  NavMeshLink_NoNavMesh = 0, // No Navmesh is loaded underneath, i.e. no ActiveCell at the CellPos of the node
36  NavMeshLink_Inside = 1, // A NavMesh is loaded, and the Node is on the NavMesh
37 
38  NavMeshLink_Undefined = KyUInt32MAXVAL, // Link Status is undefined yet
39  };
40 
41 public:
42  AbstractGraphNodeLink()
43  : m_navMeshLinkStatus(NavMeshLink_Undefined)
44  {}
45 
46  bool CanTraverse() const { return m_pairedNodeIdx.IsValid(); }
47 
48 public:
49  LoadedAbstractGraphNodeIdx m_pairedNodeIdx; //< gives the node in a neighbor graph, this node is paired to
50  NavMeshLinkStatus m_navMeshLinkStatus;
51 };
52 
53 
54 class AbstractGraph
55 {
56  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
57  KY_CLASS_WITHOUT_COPY(AbstractGraph)
58  KY_REFCOUNT_MALLOC_FREE(AbstractGraph)
59 
60 public:
61  static Ptr<AbstractGraph> Create(AbstractGraphBlob* abstractGraphBlob, Database* database, MemoryHeap* pheap = nullptr);
62 
63  KyUInt32 GetNodeCount() const;
64 
65  Vec3f GetNodePosition(const LoadedAbstractGraphNodeIdx& node) const;
66  Vec3f GetNodePosition(AbstractGraphNodeIdx nodeIdx) const;
67 
68  // -------------------- Access to Neighbors Nodes ------------------
69 
70  KyFloat32 GetNeighborCost(AbstractGraphNodeIdx fromGraphNodeIdx, AbstractGraphNodeIdx toGraphNodeIdx) const;
71 
72  const AbstractGraphCellBlob* GetAbstractGraphCellBlob(const LoadedAbstractGraphCellIdx& cellIdx) const;
73  AbstractGraphCellGrid* GetAbstractGraphCellGrid() const;
74  Database* GetDatabase() const;
75 
76 public: // internal
77  KyUInt32 GetIndexInCollection() const { return m_abstractGraphIdx; }
78  void SetIndexInCollection(KyUInt32 indexInCollection);
79 
80  bool IsNodePaired(const LoadedAbstractGraphNodeIdx& node) const;
81  bool IsNodePaired(AbstractGraphNodeIdx nodeIdx) const;
82 
83  // Debug-only, used in tests, not needed otherwise, the VisualDebug uses Blobs instead of DisplayLists
84  enum DebugDisplay
85  {
86  DebugDisplay_AbstractEdges = 1 << 0,
87  DebugDisplay_CellBoxCoverage = 1 << 1,
88  DebugDisplay_All = KyUInt32MAXVAL
89  };
90  void Display(DisplayList& displayList, const Color& color, DebugDisplay debugDisplay = DebugDisplay_All);
91 
92 public:
93  Database* m_database;
94  const AbstractGraphBlob* m_blob;
95  AbstractGraphNodeLink* m_links; // for each graph nodes gives link information about the node in the neighbor AbstractGraph, and the Navmesh
96  AbstractGraphIdx m_abstractGraphIdx;
97 };
98 
99 }
100 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_REFCOUNT_MALLOC_FREE(ClassName)
Specific to RefCounting, no inheritance involved, used to make RefCount-able classes compatible with ...
Definition: memory.h:141
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32