gwnavruntime/database/navgraphmanager.h Source File

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