gwnavruntime/navgraph/navgraph.h Source File

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