gwnavruntime/queries/dynamicnavmeshquery.h Source File

dynamicnavmeshquery.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 
8 // Primary contact: LASI - secondary contact: NOBODY
9 #ifndef Navigation_TagVolumeQuery_H
10 #define Navigation_TagVolumeQuery_H
11 
22 
23 
24 namespace Kaim
25 {
26 class TriangulatorOutput;
27 class ScopedDisplayList;
28 class TagVolume;
29 class SweepLineOutput;
30 class TriangulatorOutput;
31 class DynamicNavFloor;
32 
33 typedef Collection<Ptr<TagVolume>, MemStat_NavData> TagVolumeCollection;
34 
35 enum MergerDebugDisplayListType
36 {
37  MERGER_DEBUG_DISPLAYLIST_INPUT_TAGVOLUMES,
38  MERGER_DEBUG_DISPLAYLIST_ROUND_SNAPPING,
39  MERGER_DEBUG_DISPLAYLIST_EDGE_CULLING,
40  MERGER_DEBUG_DISPLAYLIST_POLYGON_SCAN_INPUT,
41  MERGER_DEBUG_DISPLAYLIST_POLYGON_SCAN_OUTPUT,
42  MERGER_DEBUG_DISPLAYLIST_TRIANGULATION,
43  MERGER_DEBUG_DISPLAYLIST_COUNT
44 };
45 
48 {
51 
52  DYNNAVMESH_COLLECT_TAGVOLUME_FOR_NAVFLOOR, // 2
53  DYNNAVMESH_EXTRACTING_ALL_NAVTAGS, // 3
54  DYNNAVMESH_EXTRACTING_TAGVOLUMES_CONTOURS, // 4
55  DYNNAVMESH_EXTRACTING_NAVFLOOR_CONTOUR, // 5
56  DYNNAVMESH_ROUND_SNAPPING, // 6
57  DYNNAVMESH_SWEEP_LINE_SORT_INPUT, // 7
58  DYNNAVMESH_SWEEP_LINE_SCAN, // 8
59  DYNNAVMESH_SWEEP_LINE_SORT_OUTPUT, // 9
60  DYNNAVMESH_BUILD_POLYGONS_INIT, // 10
61  DYNNAVMESH_BUILD_POLYGONS_PROCESS, // 11
62  DYNNAVMESH_TRIANGULATE_POLYGONS_INIT, // 12
63  DYNNAVMESH_TRIANGULATE_POLYGONS_PROCESS, // 13
64  DYNNAVMESH_BUILD_DYNAMIC_NAVFLOOR, // 14
65  DYNNAVMESH_BUILD_FIX_VERTEX_ALTITUDES, // 15
66  DYNNAVMESH_BUILD_NAVFLOORBLOB, // 16
67 
77 
79 };
80 
84 {
85 
86 public:
87  static QueryType GetStaticType() { return TypeDynamicNavMesh; }
88  virtual QueryType GetType() const { return TypeDynamicNavMesh; }
89 
91  virtual ~DynamicNavMeshQuery();
92 
96  void BindToDatabase(Database* database);
97  void Initialize(NavCell* navCell, const TagVolumeCollection* integratedTagVolumesAtCellPos, const TagVolumeCollection* newTagVolumes);
98 
99  virtual void Advance(WorkingMemory* workingMemory);
100  virtual void ReleaseWorkingMemoryOnCancelDuringProcess(WorkingMemory* workingMemory = KY_NULL);
102  DynamicNavMeshQueryResult GetResult() const { return m_result; };
104  // ---------------------------------- Accessors ----------------------------------
105  const PixelPos& GetCellOriginPixel() const { return m_cellOriginPixel; }
106 
107  //debug and profile
108  void SetDebugDisplayLists(KyArray<ScopedDisplayList*> displayLists) { m_debugDisplayLists = displayLists; }
109  const DynamicNavMeshQueryStats& GetStats() const { return m_stats; }
110 
111  void SetResult(DynamicNavMeshQueryResult result) { m_result = result; };
112 
113 private:
114  // Main function
115  // does the following:
116  // 0. ExtractInputDataFromNavFloor
117  // 1. BreakEdgeIntersections
118  // 2. TagAndCullEdges
119  // 3. TriangulatePolygonWithHoles
120  // 4. ComputeVerticesAltitudesFromNavFloor
121  // 5. BuildNavFloorFromTriangulatorOutput
122 
123  // And here are the signatures
124 
125  // Core functions
126  KyResult TagAndCullEdges(WorkingMemory* workingMemory);
127  KyResult SortSweepLineOutput(WorkingMemory* workingMemory);
128 
129  enum InitBuildPolygonResult { InitBuildPolygonResult_ReadyToBuild, InitBuildPolygonResult_NothingToDo } ;
130  KyResult InitBuildPolygon(WorkingMemory* workingMemory, InitBuildPolygonResult& initBuildPolygonResult);
131  enum BuildPolygonResult { BuildPolygonsResult_Finish, BuildPolygonsResult_InProcess} ;
132  KyResult BuildPolygon(WorkingMemory* workingMemory, BuildPolygonResult& buildPolygonsResult);
133 
134  KyResult InitPolygonTriangulation(WorkingMemory* workingMemory);
135 
136  KyResult PreparePolygonWithHolesTriangulation(WorkingMemory* workingMemory);
137 
138  enum TriangulatePoygonResult { TriangulatePoygonResult_Finish, TriangulatePoygonResult_GoOn } ;
139  KyResult TriangulatePoygon(WorkingMemory* workingMemory, TriangulatePoygonResult& triangulatePoygonResult);
140 
141  KyResult ComputeVerticesAltitudes(WorkingMemory* workingMemory);
142  KyResult FillDynamicNavFloorFromTriangulatorOutputs(WorkingMemory* workingMemory, KyArrayPOD<const SweepLineOutputEdgePiece*>& edgesForEdges);
143  KyResult FixHalfEdgeTypeInDynamicNavFloor(WorkingMemory* workingMemory, const KyArrayPOD<const SweepLineOutputEdgePiece*>& edgesForEdges);
144 
145  // Output build
146  KyResult BuildNavFloorFromTriangulatorOutput(WorkingMemory* workingMemory);
147 
148  KyResult BuildFinalBlobFromDynamicNavFloor(WorkingMemory* workingMemory);
149 
150  // local accessors and utilities
151  enum CollectTagVolumeResult { CollectTagVolume_NothingToDo, CollectTagVolume_NeedToComputeDynamicNavFloor, CollectTagVolume_NeedToRestoreStaticNavFloor };
152  KyResult CollectTagVolumesImpactingNavCell(WorkingMemArray<TagVolume*>& allTagVolumes, CollectTagVolumeResult& collectTagVolumeResult);
153  KyResult CollectTagVolumesToIntegrateImpactingNavCell(WorkingMemArray<TagVolume*>& allTagVolumes, const CellPos& cellPos, KyUInt32& newTagVolumeCount);
154  KyResult CollectTagVolumesToRemoveImpactingNavCell(WorkingMemArray<TagVolume*>& allTagVolumes, KyUInt32& tagVolumeToRemoveCount);
155 
156  void SetResultAndFinish(DynamicNavMeshQueryResult result, WorkingMemory* workingMemory)
157  {
158  SetResult(result);
159  SetFinish(workingMemory);
160  }
161  void SetFinish(WorkingMemory* workingMemory);
162 public: // Internal
163  ScopedDisplayList* GetDisplayList(KyUInt32 index) const;
164 public:
166  NavCell* m_navCell;
167  PixelPos m_cellOriginPixel;
168  const TagVolumeCollection* m_integratedTagVolumesAtCellPos;
169  const TagVolumeCollection* m_newTagVolumes;
170 
173  KyArray<Ptr<BlobHandler<NavFloorBlob> > > m_resultNavfloorHandlers;
174 private:
176 
177  //debug and profile
178  KyArray<ScopedDisplayList*> m_debugDisplayLists;
179  DynamicNavMeshQueryStats m_stats;
180 };
182 KY_INLINE ScopedDisplayList* DynamicNavMeshQuery::GetDisplayList(KyUInt32 index) const
183 {
184 #ifndef KY_BUILD_SHIPPING
185  return m_debugDisplayLists.GetCount() > index ? m_debugDisplayLists[index] : KY_NULL;
186 #else
187  KY_UNUSED(index);
188  return KY_NULL;
189 #endif
190 }
191 }
192 
193 
194 
195 
196 
197 #endif //Navigation_RayCanGoQuery_H
198 
Indicates the query was successfully processed.
Definition: dynamicnavmeshquery.h:78
virtual void Advance(WorkingMemory *workingMemory)
This function is called by the QueryQueue to process one step on the query.
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
Indicates an error occurred while computing the altitude of the dynamic navmesh.
Definition: dynamicnavmeshquery.h:74
Indicates an unknown error occurred during the query processing.
Definition: dynamicnavmeshquery.h:76
DynamicNavMeshQueryResult m_result
Updated during processing to indicate the result of the query.
Definition: dynamicnavmeshquery.h:184
DynamicNavMeshQueryResult GetResult() const
Read accessor for m_result.
Definition: dynamicnavmeshquery.h:103
Indicates an error occurred while culling edges.
Definition: dynamicnavmeshquery.h:71
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
Indicates an error occurred while building polygons from culled edges.
Definition: dynamicnavmeshquery.h:72
#define KY_NULL
Null value.
Definition: types.h:247
NavCell * m_navCell
Input Data.
Definition: dynamicnavmeshquery.h:174
KyArray< Ptr< BlobHandler< NavFloorBlob > > > m_resultNavfloorHandlers
Output NavFloors with TagVolumes integrated remains to size 0 if nothing changed in this...
Definition: dynamicnavmeshquery.h:181
This class is a runtime wrapper of a NavCellBlob.
Definition: navcell.h:33
virtual void ReleaseWorkingMemoryOnCancelDuringProcess(WorkingMemory *workingMemory=0)
Called when a query is canceled in FlushCommands while its status is QueryInProcess to make sure that...
Indicates that the navfloor currently being processed is no longer valid.
Definition: dynamicnavmeshquery.h:68
Base class for all the queries that need to be time-sliced.
Definition: iquery.h:306
The DynamicNavMeshQuery is used to recompute a NavCell impacted by newly projected TagVolumes or remo...
Definition: dynamicnavmeshquery.h:83
QueryType
Enumerates all the type of query.
Definition: iquery.h:29
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
Indicates an error occurred while triangulating the newly obtained polygons.
Definition: dynamicnavmeshquery.h:73
Indicates that insufficient working memory caused the query to stop.
Definition: dynamicnavmeshquery.h:69
This class defines a two-dimensional vector whose coordinates are stored using 32-bit integers...
Definition: vec2i.h:26
Definition: gamekitcrowddispersion.h:20
Indicates that.
Definition: dynamicnavmeshquery.h:75
Indicates that the query has not yet been initialized.
Definition: iquery.h:346
void BindToDatabase(Database *database)
Binds the query with the specified Database, clears all the inputs and outputs and sets all other par...
ScopedDisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:136
Indicates the query has not yet been launched.
Definition: dynamicnavmeshquery.h:50
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
DynamicNavMeshQueryResult
Enumerates the possible results of a DynamicNavMeshQuery.
Definition: dynamicnavmeshquery.h:47
Indicates that the query has not yet been launched.
Definition: iquery.h:347
Indicates the query has not yet been initialized.
Definition: dynamicnavmeshquery.h:49
void Initialize()
Should be called by the derived class before trying to perform the query or to push it in a QueryQueu...
Definition: iquery.h:404
Indicates an error occurred while computing the intersections.
Definition: dynamicnavmeshquery.h:70