gwnavruntime/database/navcellgrid.h Source File

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