gwnavruntime/navgraph/navgraph.h Source File

navgraph.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 
12 
13 namespace Kaim
14 {
15 
16 class ConnectedNavGraph;
17 class NavGraphMemoryManager;
18 class NavData;
19 
22 class NavGraph
23 {
24  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
27 
28 public: // ------------------------------ Functions -----------------------------
29  void OnRemove();
30  bool IsStillLoaded() const;
31  bool IsActive() const;
32 
33  const NavGraphEdgeInfo& GetNavGraphEdgeInfo(const NavGraphEdgeSmartIdx& edgeIdInGraph) const;
34  const NavGraphBlob* GetNavGraphBlob() const;
35 
36  void SetIdxInTheActiveDataBuffer(NavGraphIdxInActiveData idxInTheBufferOfStitchedGraph);
37  NavGraphIdxInActiveData GetIdxInTheActiveDataBuffer() const;
38 
39  GraphVertexData& GetGraphVertexData(NavGraphVertexIdx vertexIdx) const;
40  GraphEdgeData& GetEdgeData(NavGraphEdgeSmartIdx navGraphEdgeSmartIdx) const;
41 
42  KyUInt32 GetIdxInTheBufferOfNavGraph() const { return GetIndexInCollection(); }
43 
44  KyUInt32 GetIndexInCollection() const { return m_indexInCollection; }
45  void SetIndexInCollection(KyUInt32 indexInCollection) { m_indexInCollection = indexInCollection; }
46 
47  void ComputeAllCellPosOfVerticesAndCellBox();
48 
49  static KyUInt32 ComputeTotalSizeForNavGraph(const NavGraphBlob* navGraphBlob);
50  static Ptr<NavGraph> Create(const NavGraphBlob* navGraphBlob, Database* database, MemoryHeap* pheap = 0);
51 
52 private:
53  void DebugCheckIsStillLoaded() const;
54 
55 public:
56  Database* m_database;
57  KyUInt32 m_indexInCollection;
58  CellBox m_cellBox; // the cellBox of all the vertices in the Database
59  NavGraphIdxInActiveData m_idxInTheActiveDataBuffer;
60  const NavGraphBlob* m_navGraphBlob;
61  NavTag* m_navTags; // the navTag presents in the NavFloorBlob are copied in the navGraph.
62 
63  GraphVertexData* m_vertexDatas;
64  GraphEdgeData* m_edgeDatas;
65 
66  NavData* m_navData; // For visual debug purpose
67 };
68 
69 KY_INLINE void NavGraph::DebugCheckIsStillLoaded() const
70 {
71  KY_LOG_ERROR_IF(IsStillLoaded() == false, ("You Cannot call this function if graph has been unloaded"));
72 }
73 
74 KY_INLINE const NavGraphBlob* NavGraph::GetNavGraphBlob() const
75 {
76  DebugCheckIsStillLoaded();
77  return m_navGraphBlob;
78 }
79 
80 KY_INLINE void NavGraph::SetIdxInTheActiveDataBuffer(NavGraphIdxInActiveData idxInTheBufferOfStitchedGraph)
81 {
82  DebugCheckIsStillLoaded();
83  m_idxInTheActiveDataBuffer = idxInTheBufferOfStitchedGraph;
84 }
85 
86 KY_INLINE NavGraphIdxInActiveData NavGraph::GetIdxInTheActiveDataBuffer() const
87 {
88  DebugCheckIsStillLoaded();
89  return m_idxInTheActiveDataBuffer;
90 }
91 
92 KY_INLINE GraphVertexData& NavGraph::GetGraphVertexData(NavGraphVertexIdx vertexIdx) const
93 {
94  DebugCheckIsStillLoaded();
95  return m_vertexDatas[vertexIdx];
96 }
97 KY_INLINE GraphEdgeData& NavGraph::GetEdgeData(NavGraphEdgeSmartIdx navGraphEdgeSmartIdx) const
98 {
99  DebugCheckIsStillLoaded();
100  return m_edgeDatas[m_vertexDatas[navGraphEdgeSmartIdx.GetStartVertexIdx()].m_startIdxInEdgeDataArray + navGraphEdgeSmartIdx.GetNeighborVertexIdx()];
101 }
102 
103 KY_INLINE bool NavGraph::IsActive() const { return GetIdxInTheActiveDataBuffer() != NavGraphIdxInActiveData_Invalid; }
104 KY_INLINE bool NavGraph::IsStillLoaded() const { return m_navGraphBlob != nullptr; }
105 KY_INLINE void NavGraph::OnRemove() { m_navGraphBlob = nullptr; }
106 
107 
108 }
109 
110 
111 
The NavGraphBlob contains the static data of a NavGraph.
Definition: navgraphblob.h:19
KyUInt32 NavGraphVertexIdx
An index that uniquely identifies a single vertex within the set of vertices owned by a NavGraph...
Definition: navgraphtypes.h:45
2d axis aligned box of 32bits integers. Very Important: CountX() returns m_max.x - m_min...
Definition: box2i.h:17
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 NavData class is the object containing navigation data that will be added to one Database...
Definition: navdata.h:39
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:57
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
This class is a runtime wrapper of a NavGraphBlob, it gathers all the runtime information associated ...
Definition: navgraph.h:22