gwnavruntime/database/navcellgrid.h Source File

navcellgrid.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_NavcellGrid_H
9 #define Navigation_NavcellGrid_H
10 
18 
19 
20 namespace Kaim
21 {
22 
23 class NavCellBlob;
24 class NavCell;
25 class NavMeshElement;
26 class NavGraphManager;
27 class NavGraphLinker;
28 class ActiveGuids;
29 class Database;
30 class DynamicNavMeshQuery;
31 class TagVolume;
32 class StaticToDynamicHalfEdge;
33 
34 typedef Collection<NavGraphVertexRawPtr, MemStat_NavData> NavGraphVertexCollection;
35 typedef Collection<Ptr<TagVolume>, MemStat_NavData> TagVolumeCollection;
36 
40 class NavCellPosInfo
41 {
42  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
43 public:
45  ~NavCellPosInfo();
46  void Clear();
47  void CopyFrom(NavCellPosInfo& other);
48 
49 public:
50  SmallPtrTrackedCollection<NavCell> m_navCellVersions;
51  Pool<NavGraphVertexCollection>::Key m_navGraphVertexCollectionKey;
52  Pool<TagVolumeCollection>::Key m_integratedTagVolumeCollectionKey;
53  bool m_navCellActivenessChanged;
54  bool m_onlyActiveFloorVersionChange;
55 };
56 
62 class NavCellGrid
63 {
64  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
66 public:
67  NavCellGrid(Database* database);
68  ~NavCellGrid();
69 
70  void Clear();
71 
72  void EnlargeGrid(const CellBox& cellBox);
73 
74  // This function insert all the navCell of a NavMeshElement in the grid.
75  void InsertNavMeshElement(NavMeshElement* navMeshElement);
76 
77  // This function remove all the navCell of the NavMeshElement from the grid.
78  void RemoveNavMeshElement(NavMeshElement* navMeshElement);
79 
80  void UpdateStitchOneToOneAndLaunchRuntimeStitchQueries(CellBox& cellBox, QueryProcessMode queryProcessMode);
81  void UnStitch1To1EdgesInNavCellToRemoveOrInactivate(const CellBox& cellBox);
82  void StitchAllNew1To1EdgesInNavCellToActivateAndTagPotentialRunTimeStitchNeed(const CellBox& cellBox);
83  void LaunchAllRunTimeStitchQuery(const CellBox& cellBox, QueryProcessMode queryProcessMode);
84 
85  void ComputeCellNextActivenessStatusAndLaunchDynamicNavMeshQueries(const CellBox& cellBox, QueryProcessMode queryProcessMode);
86 
87  void UpdateAndStitchActiveData(const CellBox& cellBox);
88 
89  void InsertNavGraphVertexPtrAtCellPos(const NavGraphVertexRawPtr& navGraphVertexRawPtr, const CellPos& cellPos);
90  void RemoveNavGraphVertexPtrFromCellPos(const NavGraphVertexRawPtr& navGraphVertexRawPtr, const CellPos& cellPos);
91 
92  void UpdateWithDynamicNavFloors(KyArray<Ptr<DynamicNavMeshQuery> >& queries, const CellBox& enlargeUpdateCellBox);
93 
94  TagVolumeCollection* GetTagVolumeCollection(NavCellPosInfo& navCellPosInfo);
95  const TagVolumeCollection* GetTagVolumeCollection(const NavCellPosInfo& navCellPosInfo) const;
96  TagVolumeCollection* CreateTagVolumeCollection(NavCellPosInfo& navCellPosInfo);
97 
98  void ProcessNavCellToRemoveOrInactivate(const CellBox& cellBox);
99  void PostProcessRunTimeStitchQueries(CellBox& enlargedCellBox);
100  void UpdateAvailableNavFloorsInNavCell(NavCell* navCell, Ptr<BlobHandler<NavFloorBlob> >* resultNavfloorHandlers);
101  void UpdateActiveNavFloorsInActiveData(const CellBox& cellBox, const CellBox& enlargedCellBox);
102  void StitchAllActiveNavFloors(const CellBox& enlargedCellBox);
103  void RemoveAllFloorFromCorrespondingActiveCell(NavCell* navCell);
104 private:
105  void InsertNavCell(NavCell* navCell);
106  void RemoveNavCell(NavCell* navCell);
107 
108  void ComputeCellNextActivenessStatus(NavCellPosInfo& navCellPosInfo);
109  void LaunchDynamicNavMeshQueries(NavCellPosInfo& navCellPosInfo, TagVolumeCollection* integratedTagVolumes, QueryProcessMode queryProcessMode);
110  void SelectGuidCompoundCompatibleVersions(NavCellPosInfo& navCellPosInfo);
111  void SortCompatibleVersionsAndWhichNavCellToActivate(NavCellPosInfo& navCellPosInfo);
112 
113  void TryToConnectAllUnConnectedNavGraphVertexInCell(NavCellPosInfo& navCellPosInfo);
114  void DeleteNavGraphVertexCollectionOfNavCellPosInfo(NavCellPosInfo& navCellPosInfo);
115 
116  void DeleteTagVolumeCollectionOfNavCellPosInfo(NavCellPosInfo& navCellPosInfo);
117 
118  void UpdateActiveDataWithNewNavfloors(const CellBox& cellBox);
119 
120  void BuildAndStoreDynamicFloorsAtCellPosBlob(NavCell** navCells, KyUInt32 navCellCount);
121 public:
122  Database* m_database;
123  NavFloorStitcher m_floorStitcher;
124  NavCellPosInfo* m_bufferOfNavCellPosInfo;
125 
126 private :
127  MemoryHeap* m_memoryHeapForActiveNavFloorArray;
128  Pool<NavGraphVertexCollection> m_poolOfNavGraphVertexCollection;
129  Pool<TagVolumeCollection> m_poolOfTagVolumeCollection;
130  BitFieldMemStat<MemStat_NavData> m_stitchedCellIsDiscarded;
131  KyArrayPOD<NavCell*, MemStat_NavData> m_stitchedCellVersions;
132 };
133 
134 KY_INLINE void NavCellGrid::DeleteNavGraphVertexCollectionOfNavCellPosInfo(NavCellPosInfo& navCellPosInfo)
135 {
136  m_poolOfNavGraphVertexCollection.Delete(navCellPosInfo.m_navGraphVertexCollectionKey);
137  navCellPosInfo.m_navGraphVertexCollectionKey.Invalidate();
138 }
139 
140 KY_INLINE TagVolumeCollection* NavCellGrid::GetTagVolumeCollection(NavCellPosInfo& navCellPosInfo)
141 {
142  return navCellPosInfo.m_integratedTagVolumeCollectionKey.IsValid() ? &m_poolOfTagVolumeCollection.Get(navCellPosInfo.m_integratedTagVolumeCollectionKey) : KY_NULL;
143 }
144 
145 KY_INLINE const TagVolumeCollection*NavCellGrid:: GetTagVolumeCollection(const NavCellPosInfo& navCellPosInfo) const
146 {
147  return navCellPosInfo.m_integratedTagVolumeCollectionKey.IsValid() ? &m_poolOfTagVolumeCollection.Get(navCellPosInfo.m_integratedTagVolumeCollectionKey) : KY_NULL;
148 }
149 
150 }
151 
152 #endif //Navigation_NavcellGrid_H
153 
General purpose array for movable objects that DOES NOT require construction/destruction.
Definition: kyarray.h:156
This class is a runtime wrapper of a NavMeshElementBlob.
Definition: navmeshelement.h:24
This class represents a two-dimensional axis-aligned bounding box whose dimensions are stored using 3...
Definition: box2i.h:119
The NavFloorBlob contains a connected and not overlapping part of triangle mesh static data within a ...
Definition: navfloorblob.h:42
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
#define KY_NULL
Null value.
Definition: types.h:247
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:45
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
This class is a runtime wrapper of a NavCellBlob.
Definition: navcell.h:33
The DynamicNavMeshQuery is used to recompute a NavCell impacted by newly projected TagVolumes or remo...
Definition: dynamicnavmeshquery.h:83
This object gather all the data located at a CellPos in the CellPos-bases grid of the NavCellGrid obj...
Definition: navcellgrid.h:41
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
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
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexrawptr.h:36
This class is an internal class used to manage all the NavCell in a grid.
Definition: navcellgrid.h:66