gwnavruntime/abstractgraph/abstractgraphcellgrid.h Source File

abstractgraphcellgrid.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 #ifndef Navigation_AbstractGraphCellGrid_H
8 #define Navigation_AbstractGraphCellGrid_H
9 
11 
16 
17 
18 
19 namespace Kaim
20 {
21 
22 class Database;
23 class AbstractGraph;
24 class AbstractGraphBlob;
25 class NavMeshGenParameters;
26 class ScopedDisplayList;
27 
28 
29 class AbstractGraphCell
30 {
31  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
32 public:
33  LoadedAbstractGraphCellIdx m_graphCellIdx;
34  // KY_TODO maintain association AbstractGraphCell with NavCellPosInfo ?
35 };
36 
37 
38 class AbstractGraphCellGrid
39 {
40  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
41 
42 public:
43  AbstractGraphCellGrid(Database* database)
44  : m_database(database)
45  , m_abstractGraphCellBuffer(KY_NULL)
46  , m_abstractGraphCellBufferSize(0)
47  , m_altitudeTolerance(0.5f)
48  , m_abstractGraphChangeIdx(0)
49  {}
50 
51  ~AbstractGraphCellGrid() { Clear(); }
52 
53  void Clear();
54 
55  void EnlargeGrid(const CellBox& cellBox);
56 
57  AbstractGraph* InsertAbstractGraph(AbstractGraphBlob* abstractGraphBlob);
58  void RemoveAbstractGraph(AbstractGraph* abstractGraph);
59 
60  void UpdateNavMeshLinkStatus(CellBox cellBox);
61 
62 private:
63  KyResult CheckGenerationParameters(const NavMeshGenParameters& navMeshGenParameters);
64 
65 public: //internal
66  LoadedAbstractGraphCellIdx GetAbstractGraphCellIdx(const CellPos& cellPos) const;
67  AbstractGraph* GetAbstractGraph(const LoadedAbstractGraphNodeIdx& node) const;
68  AbstractGraph* GetAbstractGraph(const LoadedAbstractGraphCellIdx& cell) const;
69  AbstractGraph* GetAbstractGraph(const CellPos& cellPos) const;
70 
71  // used only in unittests while debugging, not needed otherwise, the VisualDebug uses Blobs instead of ScopedDisplayLists
72  void Display(ScopedDisplayList& displayList);
73 
74  // Must not be accessed directly. It is called by AbstractGraph::SetIndexInCollection
75  void SetAbstractGraphIndexInCollection(AbstractGraph* abstractGraph, KyUInt32 newIndexInCollection);
76 
77 public:
78  Database* m_database;
79  AbstractGraphCell* m_abstractGraphCellBuffer;
80  KyInt32 m_abstractGraphCellBufferSize;
81  CellBox m_cellBox;
82  KyFloat32 m_altitudeTolerance;
83  TrackedCollection< Ptr<AbstractGraph>, MemStat_NavData> m_abstractGraphs;
84  KyUInt32 m_abstractGraphChangeIdx;
85 };
86 
87 
88 
89 }
90 
91 #endif
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:34
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
#define KY_NULL
Null value.
Definition: types.h:247
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
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43