gwnavruntime/abstractgraph/abstractgraphcellgrid.h Source File

abstractgraphcellgrid.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 
10 
15 
16 
17 
18 namespace Kaim
19 {
20 
21 class Database;
22 class AbstractGraph;
23 class AbstractGraphBlob;
24 class NavMeshGenParameters;
25 class DisplayList;
26 
27 
28 class AbstractGraphCell
29 {
30  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
31 public:
32  LoadedAbstractGraphCellIdx m_graphCellIdx;
33  // KY_TODO maintain association AbstractGraphCell with NavCellPosInfo ?
34 };
35 
36 
37 class AbstractGraphCellGrid
38 {
39  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
40 
41 public:
42  AbstractGraphCellGrid(Database* database)
43  : m_database(database)
44  , m_abstractGraphCellBuffer(nullptr)
45  , m_abstractGraphCellBufferSize(0)
46  , m_altitudeTolerance(0.5f)
47  {}
48 
49  ~AbstractGraphCellGrid() { Clear(); }
50 
51  void Clear();
52 
53  void EnlargeGrid(const CellBox& cellBox);
54 
55  AbstractGraph* InsertAbstractGraph(AbstractGraphBlob* abstractGraphBlob);
56  void RemoveAbstractGraph(AbstractGraph* abstractGraph);
57 
58  void UpdateNavMeshLinkStatus(CellBox cellBox);
59 
60 private:
61  KyResult CheckGenerationParameters(const NavMeshGenParameters& navMeshGenParameters);
62 
63 public: //internal
64  LoadedAbstractGraphCellIdx GetAbstractGraphCellIdx(const CellPos& cellPos) const;
65  AbstractGraph* GetAbstractGraph(const LoadedAbstractGraphNodeIdx& node) const;
66  AbstractGraph* GetAbstractGraph(const LoadedAbstractGraphCellIdx& cell) const;
67  AbstractGraph* GetAbstractGraph(const CellPos& cellPos) const;
68 
69  // used only in tests while debugging, not needed otherwise, the VisualDebug uses Blobs instead of DisplayLists
70  void Display(DisplayList& displayList);
71 
72  // Must not be accessed directly. It is called by AbstractGraph::SetIndexInCollection
73  void SetAbstractGraphIndexInCollection(AbstractGraph* abstractGraph, KyUInt32 newIndexInCollection);
74 
75 public:
76  Database* m_database;
77  AbstractGraphCell* m_abstractGraphCellBuffer;
78  KyInt32 m_abstractGraphCellBufferSize;
79  CellBox m_cellBox;
80  KyFloat32 m_altitudeTolerance;
81  TrackedCollection< Ptr<AbstractGraph>, MemStat_NavData> m_abstractGraphs;
82 };
83 
84 
85 
86 }
87 
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:31
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:30
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
float KyFloat32
float
Definition: types.h:32