gwnavruntime/queries/utils/basemultidestinationpathfinderquery.h Source File

basemultidestinationpathfinderquery.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 
8 
9 #pragma once
10 
22 
23 
24 namespace Kaim
25 {
26 
27 class Path;
28 
31 {
34 
35  // --------------------- Done once for all destinations ----------------------------
38 
39  // --------------------- Done for each destination ----------------------------
51 
52  // --------------------- Possible results at the end of query ----------------------------
58 
65 
67 
68  // --------------------- Used individually for m_resultPerDestination ----------------------------
76 };
77 
81 {
86 };
87 
88 
89 static const AStarNodeIndex AStarNodeIndex_FirstDestNode = 1;
90 
91 class PathFinderPoint
92 {
93 public:
94  PathFinderPoint() { Clear(); }
95 
96  void Clear()
97  {
99  m_trianglePtr.Invalidate();
100  m_navGraphEdgePtr[0].Invalidate();
101  m_navGraphEdgePtr[1].Invalidate();
102  m_navGraphVertexPtr.Invalidate();
103  m_navGraphVertexPtr.Invalidate();
104  }
105 
106  void SetPosition(const Vec3f& pos3f) { m_pos3f = pos3f; }
107  void SetTrianglePtr(const NavTrianglePtr& destTrianglePtr);
108  void SetNavGraphEdgePtr(const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode);
109  void SetNavGraphVertexPtr(const NavGraphVertexPtr& startNavGraphVertexPtr);
110 
111 public:
112  NavTrianglePtr m_trianglePtr;
113  NavGraphEdgePtr m_navGraphEdgePtr[2];
114  NavGraphVertexPtr m_navGraphVertexPtr;
115  Vec3f m_pos3f;
116  Vec3f m_insidePos3f;
117 };
118 
121 {
122 public:
123  static QueryType GetStaticType() { return TypeMultiDestinationPathFinderQuery; }
124  virtual QueryType GetType() const { return TypeMultiDestinationPathFinderQuery; }
125  virtual void BuildQueryBlob(BaseBlobHandler* blobHandler);
126  virtual void InitFromQueryBlob(World* world, void* blob);
127  virtual Ptr<BaseBlobHandler> CreateQueryBlobHandler() { return CreateStaticQueryBlobHandler(); }
128  static Ptr<BaseBlobHandler> CreateStaticQueryBlobHandler();
129 
130  MultiDestinationPathFinderQueryResult GetResult() const { return m_result; }
131  KyFloat32 GetFromOutsideNavMeshDistance() const { return m_traversalParams.m_fromOutsideNavMeshDistance; }
132  KyFloat32 GetToOutsideNavMeshDistance() const { return m_traversalParams.m_toOutsideNavMeshDistance; }
133 
134  const Vec3f& GetStartPos() const { return m_start.m_pos3f; }
135  const NavTrianglePtr& GetStartTrianglePtr() const { return m_start.m_trianglePtr; }
136  const NavGraphEdgePtr& GetStartNavGraphEdgePtr() const { return m_start.m_navGraphEdgePtr[0]; }
137  const NavGraphVertexPtr& GetStartNavGraphVertexPtr() const { return m_start.m_navGraphVertexPtr; }
138 
139  KyUInt32 GetDestCount() const { return m_destinations.GetCount(); }
140  const Vec3f& GetDestPos(KyUInt32 destIdx) const { return m_destinations[destIdx].m_pos3f; }
141  const NavTrianglePtr& GetDestTrianglePtr(KyUInt32 destIdx) const { return m_destinations[destIdx].m_trianglePtr; }
142  const NavGraphEdgePtr& GetDestNavGraphEdgePtr(KyUInt32 destIdx) const { return m_destinations[destIdx].m_navGraphEdgePtr[0]; }
143  const NavGraphVertexPtr& GetDestNavGraphVertexPtr(KyUInt32 destIdx) const { return m_destinations[destIdx].m_navGraphVertexPtr; }
144  MultiDestinationPathFinderQueryResult GetDestResult(KyUInt32 destIdx) const { return m_resultPerDestinations[destIdx]; }
145 
146  PathFinderQueryTryCanGoMode GetTryCanGoMode() const { return m_tryCanGoMode; }
147  PathFinderQueryComputeChannelMode GetComputeChannelMode() const { return m_computeChannelMode; }
148  const ChannelComputerConfig& GetChannelComputerConfig() const { return m_channelComputerConfig; }
149  KyUInt32 GetNumberOfProcessedNodePerFrame() const { return m_traversalParams.m_numberOfVisitedNodePerAdvance; }
150  Path* GetPath(KyUInt32 destIdx) const { return m_paths[destIdx]; }
151  Path* GetAbstractPath(KyUInt32 destIdx) const { return m_abstractPaths[destIdx]; }
152  KyFloat32 GetRawCost(KyUInt32 destIdx) const { return m_rawCosts[destIdx]; }
153 
154  const PositionSpatializationRange& GetPositionSpatializationRange() const { return m_traversalParams.m_positionSpatializationRange; }
155 
156  void ComputePathRefinerConfigInternals() { m_pathRefinerConfig.ComputeInternals();}
157  const PathRefinerConfig& GetPathRefinerConfig() const { return m_pathRefinerConfig; }
158  void SetPathClamperFlagMask(PathClamperFlagMask pathClamperFlagMask) { m_pathClamperFlagMask = pathClamperFlagMask; } // Call this method after BindToDatabase()
159 
160  KyUInt32 GetNavigationProfileId() const { return m_navigationProfileId; }
161 
163 
164  void BindToDatabase(Database* database);
165  void Initialize(const PathFinderPoint& start);
166  void AddDestination(const PathFinderPoint& additionalDest);
167 
168  void SetFinalOutputMode(KyUInt32 finalOutputMode) { m_finalOutputMode = finalOutputMode; }
169  void SetTryCanGoMode(PathFinderQueryTryCanGoMode tryCanGoMode) { m_tryCanGoMode = tryCanGoMode; }
170  void SetComputeChannelMode(PathFinderQueryComputeChannelMode computeChannelMode) { m_computeChannelMode = computeChannelMode; }
171  void SetChannelComputerConfig(const ChannelComputerConfig& channelComputerConfig) { m_channelComputerConfig = channelComputerConfig; }
172  void SetPropagationFilter(Ptr<CellFilter> propagationFilter) { m_propagationCellFilter = propagationFilter; }
173  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange) { m_traversalParams.m_positionSpatializationRange = positionSpatializationRange; }
174  void SetFromOutsideNavMeshDistance(KyFloat32 fromOutsideNavMeshDistance) { m_traversalParams.m_fromOutsideNavMeshDistance = fromOutsideNavMeshDistance; }
175  void SetToOutsideNavMeshDistance(KyFloat32 toOutsideNavMeshDistance) { m_traversalParams.m_toOutsideNavMeshDistance = toOutsideNavMeshDistance; }
176  void SetNumberOfProcessedNodePerFrame(KyUInt32 numberOfProcessedNodePerFrame) { m_traversalParams.m_numberOfVisitedNodePerAdvance = numberOfProcessedNodePerFrame; }
177  void SetAbstractGraphTraversalMode(PathFinderAbstractGraphTraversalMode abstractGraphTraversalMode) { m_abstractGraphTraversalMode = abstractGraphTraversalMode; }
178  void SetNavigationProfileId(KyUInt32 navigationProfileId) { m_navigationProfileId = navigationProfileId; }
179 
180 protected:
181  BaseMultiDestinationPathFinderQuery();
182  virtual ~BaseMultiDestinationPathFinderQuery() {}
183  void SetResult(MultiDestinationPathFinderQueryResult result) { m_result = result; }
184 
185  void InitTraversalParamsAndPropagationCellFilter();
186 
187  void ReplaceNodesOfShortestPathOnMiddleOfNavHalfEdge(WorkingMemory* workingMemory);
188 
189 public: // internal
190  Path* GetRawPath(KyUInt32 destIdx) const { return m_rawPaths[destIdx]; }// For Debug only.
191 
192 protected:
193  KyUInt32 m_navigationProfileId;
194 
195  // configuration
196  PathFinderQueryTryCanGoMode m_tryCanGoMode;
199 
201  KyUInt32 m_lastAdvanceDatabaseChangeIdx; // used to test if there was a change in the database since last call to Advance
202 
203  bool m_isStartTriangleHooked; // computed
204  PathFinderPoint m_start; // start
205  KyArray<PathFinderPoint> m_destinations; // destinations
206 
207  TraversalParameters m_traversalParams;// computed
208  PathRefinerConfig m_pathRefinerConfig; // configuration
209  PathClamperFlagMask m_pathClamperFlagMask; // configuration
210  PathFinderAbstractGraphTraversalMode m_abstractGraphTraversalMode; // configuration
211 
212  Ptr<CellFilter> m_propagationCellFilter; // computed
213 
214  // results
215  KyArray<Ptr<Path> > m_paths;
216  KyArray<Ptr<Path> > m_abstractPaths;
217  KyArray<Ptr<Path> > m_rawPaths; // for debug only.
218  KyArrayPOD<KyFloat32> m_rawCosts;
219 
220  KyArray<MultiDestinationPathFinderQueryResult> m_resultPerDestinations;
221 
222  MultiDestinationPathFinderQueryResult m_result; // computed Updated during processing to indicate the result of the PathFinderQueryResult query.
223 
224 protected:
225  Ptr<Path> m_currentRawPath; // computed
226 
227 public:
228  FullDebug m_fullDebug; // configuration
229 };
230 
231 KY_INLINE void PathFinderPoint::SetTrianglePtr(const NavTrianglePtr& trianglePtr)
232 {
233  m_trianglePtr = trianglePtr;
234  KY_LOG_WARNING_IF(m_navGraphEdgePtr[0].IsValid(), ("You are setting a NavTrianglePtr whereas a NavGraphEdgePtr was set too."));
235  KY_LOG_WARNING_IF(m_navGraphVertexPtr.IsValid(), ("You are setting a NavTrianglePtr whereas a NavGraphVertexPtr was set too."));
236  m_navGraphEdgePtr[0].Invalidate();
237  m_navGraphEdgePtr[1].Invalidate();
238  m_navGraphVertexPtr.Invalidate();
239 }
240 
241 KY_INLINE void PathFinderPoint::SetNavGraphEdgePtr(const NavGraphEdgePtr& navGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode)
242 {
243  m_navGraphEdgePtr[0] = navGraphEdgePtr;
244  if(navGraphEdgePathfindMode == NAVGRAPHEDGE_BIDIRECTIONAL)
245  m_navGraphEdgePtr[1] = navGraphEdgePtr.GetOppositeNavGraphEdgePtr();
246  else
247  m_navGraphEdgePtr[1].Invalidate();
248 
249  KY_LOG_WARNING_IF(m_trianglePtr.IsValid(), ("You are setting a NavGraphEdgePtr whereas a NavTrianglePtr was set too."));
250  KY_LOG_WARNING_IF(m_navGraphVertexPtr.IsValid(), ("You are setting a NavGraphEdgePtr whereas a NavGraphVertexPtr was set too."));
251  m_trianglePtr.Invalidate();
252  m_navGraphVertexPtr.Invalidate();
253 }
254 
255 KY_INLINE void PathFinderPoint::SetNavGraphVertexPtr(const NavGraphVertexPtr& navGraphVertexPtr)
256 {
257  m_navGraphVertexPtr = navGraphVertexPtr;
258  KY_LOG_WARNING_IF(m_trianglePtr.IsValid(), ("You are setting a NavGraphVertexPtr whereas a NavTrianglePtr was set too."));
259  KY_LOG_WARNING_IF(m_navGraphEdgePtr[0].IsValid(), ("You are setting a NavGraphVertexPtr whereas a NavGraphEdgePtr was set too."));
260  m_trianglePtr.Invalidate();
261  m_navGraphEdgePtr[0].Invalidate();
262  m_navGraphEdgePtr[1].Invalidate();
263 }
264 
265 }
266 
267 
KyUInt32 m_finalOutputMode
cf enum MultiDestinationPathFinderFinalOutput
Definition: basemultidestinationpathfinderquery.h:200
#define KyFloat32MAXVAL
KyFloat32 max value
Definition: types.h:71
Indicates that the cost from nodes that are on navMesh are beeing recomputed since they may have been...
Definition: basemultidestinationpathfinderquery.h:44
Indicates that insufficient working memory caused the query to stop.
Definition: basemultidestinationpathfinderquery.h:60
Indicates that all destination points are either outside or in forbidden navtag.
Definition: basemultidestinationpathfinderquery.h:55
PathFinderQueryComputeChannelMode
This enum tells if the PathFinderQuery should compute Channels around path sections laying on the Nav...
Definition: ipathfinderquery.h:25
Indicates that the refiner is done, the channel is going to be initialized for one destination...
Definition: basemultidestinationpathfinderquery.h:49
For Debug Only, fulfill m_rawPaths, no refining, no clamping, no channel making paths unsuitable for ...
Definition: basemultidestinationpathfinderquery.h:84
void SetFinalOutputMode(KyUInt32 finalOutputMode)
cf MultiDestinationPathFinderFinalOutput enum
Definition: basemultidestinationpathfinderquery.h:168
Indicates that the astar traversal algorithm has been launched, but has not yet completed.
Definition: basemultidestinationpathfinderquery.h:36
ChannelComputerConfig m_channelComputerConfig
The parameter set specific to Channels computation.
Definition: basemultidestinationpathfinderquery.h:198
Indicates that the destination point is currently processed (from MULTIDESTINATIONPATHFINDER_PROCESSI...
Definition: basemultidestinationpathfinderquery.h:70
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Indicates that the computation has been canceled.
Definition: basemultidestinationpathfinderquery.h:64
PathClamperFlag
These flags determine if some specific positions must have their altitude clamped on NavMesh...
Definition: pathclamperflag.h:15
Fulfill m_paths with refined, clamped paths with channels and m_abstractPaths for paths going through...
Definition: basemultidestinationpathfinderquery.h:85
Class that aggregates parameters that allow to configure the channel computation of a Bot...
Definition: channelcomputerconfig.h:89
Base class for MultiDestinationPathFinderQuery.
Definition: basemultidestinationpathfinderquery.h:120
Indicates that the refining process is being initialized for one destination.
Definition: basemultidestinationpathfinderquery.h:43
Indicates that no path was found for any destinations.
Definition: basemultidestinationpathfinderquery.h:57
This class is a runtime container for Autodesk Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:52
Indicates that the input channelComputerConfig is invalid.
Definition: basemultidestinationpathfinderquery.h:62
Indicates that initial CanGoQuery reached a dest from start, and the path from this dest is being com...
Definition: basemultidestinationpathfinderquery.h:40
KyFloat32 m_fromOutsideNavMeshDistance
The maximum distance from the start along the X axis and along the Y axis that will be searched for N...
Definition: traversalparams.h:54
PathFinderQueryTryCanGoMode
This enums tells if a RayCanGoQuery should be performed from start position to destination position b...
Definition: pathfinderquerytrycangomode.h:22
Indicates that a path could not be found between the start and destination point. ...
Definition: basemultidestinationpathfinderquery.h:73
An internal class that stores parameters used to control the propagation of traversals.
Definition: traversalparams.h:18
Indicates the query has not yet been initialized.
Definition: basemultidestinationpathfinderquery.h:32
Base class for all the queries that need to be time-sliced.
Definition: iquery.h:262
Indicates that the clamping algorithm has completed, but the path has not yet been built...
Definition: basemultidestinationpathfinderquery.h:48
Indicates that a path has been found between the start and destination.
Definition: basemultidestinationpathfinderquery.h:75
QueryType
Enumerates all the type of query.
Definition: iquery.h:25
Indicates that the NavTag at the destination point is forbidden.
Definition: basemultidestinationpathfinderquery.h:72
Indicates that the astar traversal algorithm is finished, and that the path found is ready to be refi...
Definition: basemultidestinationpathfinderquery.h:37
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:57
virtual QueryType GetType() const
Get query type.
Definition: basemultidestinationpathfinderquery.h:124
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that the channel is initialized, the channel is being computed for one destination.
Definition: basemultidestinationpathfinderquery.h:50
Indicates that query starting location and ending location are equals, computing a Path would have le...
Definition: basemultidestinationpathfinderquery.h:74
Indicates that the refiner is done, but the path has not yet been clamped to the navMesh.
Definition: basemultidestinationpathfinderquery.h:46
Indicates that the query has not yet been initialized.
Definition: iquery.h:295
Indicates some or all destinations have a path or an abstract path.
Definition: basemultidestinationpathfinderquery.h:66
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basemultidestinationpathfinderquery.h:53
Indicates that the astar traversal algorithm traversed AbstractGraph, and an Abstract path is being b...
Definition: basemultidestinationpathfinderquery.h:42
CAnGoQuery validated the reachability, Path will be built from the query.
Definition: basemultidestinationpathfinderquery.h:69
KyUInt32 GetFinalOutputMode() const
possible returned values are defined by MultiDestinationPathFinderFinalOutput enum ...
Definition: basemultidestinationpathfinderquery.h:162
Indicates that a computation error caused the query to stop.
Definition: basemultidestinationpathfinderquery.h:63
Indicates that all destinations are equals to starting location, computing a Path would have lead to ...
Definition: basemultidestinationpathfinderquery.h:56
Fulfill m_rawCosts.
Definition: basemultidestinationpathfinderquery.h:83
Gathers all runtime flags used to debug internal algorithms (mostly PathFinder).
Definition: fulldebug.h:14
Build m_path or m_abstractPath to the destination with the lowest cost.
Definition: basemultidestinationpathfinderquery.h:82
Indicates that the query has stopped and must be relaunched because of a change in the NavData...
Definition: basemultidestinationpathfinderquery.h:59
MultiDestinationPathFinderQueryResult
Enumerates the possible results of an AStarQuery.
Definition: basemultidestinationpathfinderquery.h:30
PathFinderQueryComputeChannelMode m_computeChannelMode
The mode toggling Channels computation.
Definition: basemultidestinationpathfinderquery.h:197
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
Indicates that the NavTag at the starting point is forbidden.
Definition: basemultidestinationpathfinderquery.h:54
Indicates that a computation error caused the query to stop.
Definition: basemultidestinationpathfinderquery.h:61
Indicates that the query has not yet been launched.
Definition: iquery.h:296
Indicates the query has not yet been launched.
Definition: basemultidestinationpathfinderquery.h:33
Indicates that the refined path of one destination is being clamped to navMesh according to the altit...
Definition: basemultidestinationpathfinderquery.h:47
PositionSpatializationRange m_positionSpatializationRange
The altitude range used to find NavMesh triangles that correspond to the start and destination points...
Definition: traversalparams.h:46
Indicates that initial CanGoQuery did not reach a dest from start, so a path must be built from the t...
Definition: basemultidestinationpathfinderquery.h:41
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:273
Indicates that the path found is being refined for one destination.
Definition: basemultidestinationpathfinderquery.h:45
MultiDestinationPathFinderFinalOutput
Usually only one of MultiDestinationPathFinderFinalOutput values is useful, but for debug purpose...
Definition: basemultidestinationpathfinderquery.h:80
float KyFloat32
float
Definition: types.h:32
Indicates that the destination point is outside the NavMesh.
Definition: basemultidestinationpathfinderquery.h:71
KyFloat32 m_toOutsideNavMeshDistance
The maximum distance from the destination along the X axis and along the Y axis that will be searched...
Definition: traversalparams.h:62