gwnavruntime/database/navgraphmanager.h Source File

navgraphmanager.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 // primary contact: JUBA - secondary contact: NOBODY
8 #ifndef Navigation_NavGraphManager_H
9 #define Navigation_NavGraphManager_H
10 
13 
14 namespace Kaim
15 {
16 class Database;
17 class NavCellGrid;
18 class NavGraphBlob;
19 class NavData;
20 
21 // The NavGraphManager manages the stitching of \NavGraphs at runtime. You should not need to interact with the
22 // NavGraphManager directly.
23 class NavGraphManager
24 {
25  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
26  KY_CLASS_WITHOUT_COPY(NavGraphManager)
27 
28 public:
29  KyUInt32 GetNumberOfNavGraph() const;
30  NavGraph* GetNavGraph(KyUInt32 index) const;
31 
32 public: // internal
33  NavGraphManager(Database* database);
34  ~NavGraphManager();
35 
36  void Clear();
37 
38  void StartInsertion();
39  NavGraph* InsertNavGraph(const NavGraphBlob* navGraphBlob, NavData* navData);
40  void EndInsertion();
41 
42  void StartRemoval();
43  void RemoveNavGraph(NavGraph* navGraph);
44  void EndRemoval();
45 
46  void LinkWaitingNavGraphs(CellBox& cellBox);
47  bool HasWaitingNavGraphs();
48 public: // internal
49  Database* m_database;
50  NavGraphLinker m_navGraphLinker;
51 
52 private:
53  KyUInt32 m_numberOfNavGraphToUpdate;
54  CellBox m_cellBox;
55 
56  Collection<NavGraph*, MemStat_NavData> m_waitingNavGraphs;
57  TrackedCollection<Ptr<NavGraph>, MemStat_NavData> m_navGraphs;
58 };
59 
60 
61 KY_INLINE void NavGraphManager::StartInsertion()
62 {
63  KY_LOG_ERROR_IF(m_numberOfNavGraphToUpdate != 0, ("At this point, the number of Graph to update must be set to 0"));
64  m_cellBox.Clear();
65 }
66 KY_INLINE void NavGraphManager::StartRemoval()
67 {
68  KY_LOG_ERROR_IF(m_numberOfNavGraphToUpdate != 0, ("At this point, the number of Graph to update must be set to 0"));
69  m_cellBox.Clear();
70 }
71 
72 KY_INLINE void NavGraphManager::EndRemoval() {}
73 
74 KY_INLINE KyUInt32 NavGraphManager::GetNumberOfNavGraph() const { return m_navGraphs.GetCount(); }
75 KY_INLINE NavGraph* NavGraphManager::GetNavGraph(KyUInt32 index) const
76 {
77  KY_DEBUG_ASSERTN(index < GetNumberOfNavGraph(), ("Bad index %u (max is %u)", index, GetNumberOfNavGraph()));
78  return m_navGraphs[index];
79 }
80 
81 KY_INLINE bool NavGraphManager::HasWaitingNavGraphs() { return m_waitingNavGraphs.IsEmpty() == false; }
82 
83 } // namespace Kaim
84 
85 #endif // Navigation_NavGraphManager_H
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:34
#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