gwnavruntime/queries/utils/basebestgraphvertexpathfinderquery.h Source File

basebestgraphvertexpathfinderquery.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: JUBA - secondary contact: NOBODY
9 #ifndef Navigation_BaseBestGraphVertexPathFinderQuery_H
10 #define Navigation_BaseBestGraphVertexPathFinderQuery_H
11 
16 
17 
18 namespace Kaim
19 {
20 
23 {
26 
36 
46 
48 };
49 
52 {
53 public:
54  static QueryType GetStaticType() { return TypeBestGraphVertexPathFinderQuery; }
55  virtual QueryType GetType() const { return TypeBestGraphVertexPathFinderQuery; }
56  virtual void BuildQueryBlob(BaseBlobHandler* blobHandler);
57  virtual void InitFromQueryBlob(World* world, void* blob);
58  virtual Ptr<BaseBlobHandler> CreateQueryBlobHandler() { return CreateStaticQueryBlobHandler(); }
59  static Ptr<BaseBlobHandler> CreateStaticQueryBlobHandler();
60 
61  // ---------------------------------- Main API functions ----------------------------------
62 
63  virtual void GetPathFinderTextResult(String&) const;
64  virtual void DisplayPropagationBounds(ScopedDisplayList& displayList) const;
65  virtual PathFinderResult GetPathFinderResult() const;
66  virtual const Vec3f* GetDestination() const;
67 
68  BestGraphVertexPathFinderQueryResult GetResult() const;
69  KyFloat32 GetPropagationRadius() const;
70  KyFloat32 GetFromOutsideNavMeshDistance() const;
71  KyFloat32 GetToOutsideNavMeshDistance() const;
72  const Vec3f& GetStartPos() const;
73  const NavTrianglePtr& GetStartTrianglePtr() const;
74  const NavGraphEdgePtr& GetStartNavGraphEdgePtr() const;
75  const NavGraphVertexPtr& GetStartNavGraphVertexPtr() const;
76  const NavTrianglePtr& GetDestTrianglePtr() const;
77  Path* GetPath() const;
78  ChannelArray* GetChannelArray() const;
79  KyUInt32 GetNumberOfProcessedNodePerFrame() const;
80 
81  const PositionSpatializationRange& GetPositionSpatializationRange() const;
82 
83  void ComputePathRefinerConfigInternals();
84  const PathRefinerConfig& GetPathRefinerConfig() const;
85 
86  void SetPathClamperFlagMask(PathClamperFlagMask pathClamperFlagMask); // Call this method after BindToDatabase()
87 
88 public: // Internal
89  // public because can be used by the Bot basic path finding helper functions
90  void BindToDatabase(Database* database);
91  void Initialize(const Vec3f& startPos);
92  void SetStartTrianglePtr(const NavTrianglePtr& startTrianglePtr);
93  void SetStartNavGraphEdgePtr(const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode);
94  void SetStartNavGraphVertexPtr(const NavGraphVertexPtr& startNavGraphVertexPtr);
95 
96 protected :
99 
100  void SetComputeChannelMode(PathFinderQueryComputeChannelMode computeChannelMode);
101  void SetChannelComputerConfig(const ChannelComputerConfig& channelComputerConfig);
102  void SetPropagationRadius(KyFloat32 propagationRadius);
103  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange);
104  void SetFromOutsideNavMeshDistance(KyFloat32 fromOutsideNavMeshDistance);
105  void SetToOutsideNavMeshDistance(KyFloat32 toOutsideNavMeshDistance);
106  void SetNumberOfProcessedNodePerFrame(KyUInt32 numberOfProcessedNodePerFrame);
107  void SetResult(BestGraphVertexPathFinderQueryResult result);
108 
109 protected :
113 
116 
118  NavGraphEdgeDirection m_navGraphEdgePathfindMode;
119 
122 
125  TraversalParameters m_traversalParams;
126  PathRefinerConfig m_pathRefinerConfig;
127  PathClamperFlagMask m_pathClamperFlagMask;
128 
129  NavGraphVertexRawPtr m_currentVertex;
130  AStarNodeIndex m_currentVertexNodeIdx;
131 
132  NavGraphVertexRawPtr m_bestVertex; // the best Vertex found so far.
133  AStarNodeIndex m_bestVertexNodeIdx;
134  Ptr<Path> m_rememberBestPathSoFar;
135 
136  KyFloat32 m_propagationRadius; // the propagation is limited to a 2d circle centered in startPos and with m_propagationRadius as radius
137 
139 };
140 
141 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetResult(BestGraphVertexPathFinderQueryResult result) { m_result = result; }
142 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetStartTrianglePtr(const NavTrianglePtr& startTrianglePtr) { m_startTrianglePtr = startTrianglePtr; }
143 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetPropagationRadius(KyFloat32 propagationRadius) { m_propagationRadius = propagationRadius; }
144 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetComputeChannelMode(PathFinderQueryComputeChannelMode mode) { m_computeChannelMode = mode; }
145 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetChannelComputerConfig(const ChannelComputerConfig& config) { m_channelComputerConfig = config; }
146 
147 KY_INLINE BestGraphVertexPathFinderQueryResult BaseBestGraphVertexPathFinderQuery::GetResult() const { return m_result; }
148 KY_INLINE const NavTrianglePtr& BaseBestGraphVertexPathFinderQuery::GetStartTrianglePtr() const { return m_startTrianglePtr; }
149 KY_INLINE Path* BaseBestGraphVertexPathFinderQuery::GetPath() const { return m_path; }
150 KY_INLINE const Vec3f* BaseBestGraphVertexPathFinderQuery::GetDestination() const { return KY_NULL; }
151 KY_INLINE KyFloat32 BaseBestGraphVertexPathFinderQuery::GetPropagationRadius() const { return m_propagationRadius; }
152 
153 KY_INLINE KyFloat32 BaseBestGraphVertexPathFinderQuery::GetFromOutsideNavMeshDistance() const { return m_traversalParams.GetFromOutsideNavMeshDistance(); }
154 KY_INLINE KyFloat32 BaseBestGraphVertexPathFinderQuery::GetToOutsideNavMeshDistance() const { return m_traversalParams.GetToOutsideNavMeshDistance(); }
155 KY_INLINE KyUInt32 BaseBestGraphVertexPathFinderQuery::GetNumberOfProcessedNodePerFrame() const { return m_traversalParams.GetNumberOfProcessedNodePerFrame(); }
156 KY_INLINE const Vec3f& BaseBestGraphVertexPathFinderQuery::GetStartPos() const { return IPathFinderQuery::GetStartPos(); }
157 
158 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetFromOutsideNavMeshDistance(KyFloat32 fromOutsideNavMeshDistance)
159 {
160  m_traversalParams.SetFromOutsideNavMeshDistance(fromOutsideNavMeshDistance);
161 }
162 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetToOutsideNavMeshDistance(KyFloat32 toOutsideNavMeshDistance)
163 {
164  m_traversalParams.SetToOutsideNavMeshDistance(toOutsideNavMeshDistance);
165 }
166 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetNumberOfProcessedNodePerFrame(KyUInt32 numberOfProcessedNodePerFrame)
167 {
168  m_traversalParams.SetNumberOfProcessedNodePerFrame(numberOfProcessedNodePerFrame);
169 }
170 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange)
171 {
172  m_traversalParams.SetPositionSpatializationRange(positionSpatializationRange);
173 }
174 KY_INLINE const PositionSpatializationRange& BaseBestGraphVertexPathFinderQuery::GetPositionSpatializationRange() const { return m_traversalParams.GetPositionSpatializationRange(); }
175 
176 KY_INLINE void BaseBestGraphVertexPathFinderQuery::ComputePathRefinerConfigInternals() { m_pathRefinerConfig.ComputeInternals();}
177 KY_INLINE const PathRefinerConfig& BaseBestGraphVertexPathFinderQuery::GetPathRefinerConfig() const { return m_pathRefinerConfig;}
178 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetPathClamperFlagMask(PathClamperFlagMask pathClamperFlagMask) { m_pathClamperFlagMask = pathClamperFlagMask; }
179 
180 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetStartNavGraphEdgePtr(const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode)
181 {
182  m_startNavGraphEdgePtr = startNavGraphEdgePtr;
183  m_navGraphEdgePathfindMode = navGraphEdgePathfindMode;
184  KY_LOG_WARNING_IF(m_startTrianglePtr.IsValid(), ("You are setting a start NavGraphEdgePtr whereas a start NavTrianglePtr was set too."));
185  KY_LOG_WARNING_IF(m_startNavGraphVertexPtr.IsValid(), ("You are setting a start NavGraphEdgePtr whereas a start NavGraphVertexPtr was set too."));
188 }
189 
190 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetStartNavGraphVertexPtr(const NavGraphVertexPtr& startNavGraphVertexPtr)
191 {
192  m_startNavGraphVertexPtr = startNavGraphVertexPtr;
193  KY_LOG_WARNING_IF(m_startTrianglePtr.IsValid(), ("You are setting a start NavGraphVertexPtr whereas a start NavTrianglePtr was set too."));
194  KY_LOG_WARNING_IF(m_startNavGraphEdgePtr.IsValid(), ("You are setting a start NavGraphVertexPtr whereas a start NavGraphEdgePtr was set too."));
197 }
198 }
199 
200 #endif // Navigation_BaseBestGraphVertexPathFinderQuery_H
ChannelComputerConfig m_channelComputerConfig
The parameter set specific to Channels computation.
Definition: ipathfinderquery.h:103
bool IsValid() const
Returns true if this object refers to a valid triangle: i.e. a triangle in a validNavFloor. see NavFloorPtr::IsValid().
Definition: navtriangleptr.h:132
NavGraphEdgeDirection m_navGraphEdgePathfindMode
Whether we should pathfind on that edge both ways or not.
Definition: basebestgraphvertexpathfinderquery.h:127
void Invalidate()
Invalidates this object.
Definition: navtriangleptr.h:134
Base class for all pathfinder queries.
Definition: ipathfinderquery.h:38
bool IsValid() const
Returns true if this object refers to a valid NavGraphVertex: i.e. a NavGraphVertex in a validNavGrap...
Definition: navgraphvertexptr.h:113
PathFinderQueryComputeChannelMode
This enum tells if the PathFinderQuery should compute Channels around path sections laying on the Nav...
Definition: ipathfinderquery.h:28
NavGraphEdgePtr m_startNavGraphEdgePtr
When this NavGraph edge is valid, that means that you want the path to start with that edge...
Definition: basebestgraphvertexpathfinderquery.h:124
Base class for BestGraphVertexPathFinderQuery.
Definition: basebestgraphvertexpathfinderquery.h:51
Indicates that the input channelComputerConfig is invalid.
Definition: basebestgraphvertexpathfinderquery.h:43
void Invalidate()
Invalidates this object.
Definition: navgraphvertexptr.h:114
Indicates the query has not yet been initialized.
Definition: basebestgraphvertexpathfinderquery.h:24
Class that aggregates parameters that allow to configure the channel computation of a Bot...
Definition: channelcomputerconfig.h:76
#define KY_NULL
Null value.
Definition: types.h:247
Indicates the query has not yet been launched.
Definition: basebestgraphvertexpathfinderquery.h:25
void Invalidate()
Invalidates this object.
Definition: navgraphedgeptr.h:130
Indicates that the astar traversal algorithm has been launched, but has not yet completed.
Definition: basebestgraphvertexpathfinderquery.h:27
This class aggregates Channels along a Path.
Definition: channelarray.h:31
Indicates that insufficient working memory caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:41
This class is a runtime container for Gameware Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:54
Ptr< Path > m_path
The Path found by the query.
Definition: ipathfinderquery.h:98
virtual const Vec3f * GetDestination() const
This function is virtual because not all the PathFinders have a preset destination, it may return KY_NULL.
Definition: basebestgraphvertexpathfinderquery.h:159
Indicates that the computation has been canceled.
Definition: basebestgraphvertexpathfinderquery.h:45
An internal class that stores parameters used to control the propagation of traversals through the Na...
Definition: traversalparams.h:23
PathFinderQueryComputeChannelMode m_computeChannelMode
The mode toggling Channels computation.
Definition: ipathfinderquery.h:102
virtual void GetPathFinderTextResult(String &) const
Fills the String with an explanation of the result. Use this to debug your pathfinder query...
Indicates that the refiner is done, the channel is going to be initialized.
Definition: basebestgraphvertexpathfinderquery.h:34
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 that the refining process is being initialized.
Definition: basebestgraphvertexpathfinderquery.h:29
Indicates that the refined path is being clamped to navMesh according to the altitude tolerance...
Definition: basebestgraphvertexpathfinderquery.h:32
NavTrianglePtr m_startTrianglePtr
The NavMesh triangle that corresponds to m_startPos3f.
Definition: basebestgraphvertexpathfinderquery.h:121
NavGraphVertexPtr m_startNavGraphVertexPtr
When this NavGraph vertex is valid, that means that you want the path to start at that vertice...
Definition: basebestgraphvertexpathfinderquery.h:130
BestGraphVertexPathFinderQueryResult m_result
Updated during processing to indicate the result of the PathFinderQueryResult query.
Definition: basebestgraphvertexpathfinderquery.h:147
Definition: gamekitcrowddispersion.h:20
Indicates that the clamping algorithm has completed, but the path has not yet been built...
Definition: basebestgraphvertexpathfinderquery.h:33
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexptr.h:22
Indicates that the query has not yet been initialized.
Definition: iquery.h:346
Indicates that the NavTag at the starting point is forbidden.
Definition: basebestgraphvertexpathfinderquery.h:38
PathFinderResult
Enumerates the possible status of a IPathFinderQuery.
Definition: ipathfinderquery.h:43
Indicates that a path has been found between the start and destination.
Definition: basebestgraphvertexpathfinderquery.h:47
ScopedDisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:136
Indicates that a path could not be found between the start and destination points.
Definition: basebestgraphvertexpathfinderquery.h:39
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
Indicates that the channel is initialized, the channel is being computed.
Definition: basebestgraphvertexpathfinderquery.h:35
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates that a computation error caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:44
bool IsValid() const
Returns true if this object refers to a valid NavGraphEdge: i.e. a NavGraphEdge in a valid NavGraph...
Definition: navgraphedgeptr.h:129
Indicates that the astar traversal algorithm is finished, and that the path found is ready to be refi...
Definition: basebestgraphvertexpathfinderquery.h:28
Indicates that the query has not yet been launched.
Definition: iquery.h:347
Vec3f m_startInsidePos3f
if m_startPos3f is slightly outside and we hook on the NavMesh, it is the computed inside pos...
Definition: basebestgraphvertexpathfinderquery.h:132
Each instance of this class uniquely identifies a single and mono-directionnal NavGraphEdge in a NavG...
Definition: navgraphedgeptr.h:25
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
BestGraphVertexPathFinderQueryResult
Enumerates the possible results of an BestGraphVertexPathFinderQuery.
Definition: basebestgraphvertexpathfinderquery.h:22
Indicates that the path found is being refined.
Definition: basebestgraphvertexpathfinderquery.h:30
Indicates that the query has stopped and must be relaunched because of a change in the NavData...
Definition: basebestgraphvertexpathfinderquery.h:40
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexrawptr.h:36
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basebestgraphvertexpathfinderquery.h:37
The class representing a path.
Definition: path.h:42
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
virtual void DisplayPropagationBounds(ScopedDisplayList &displayList) const
Fill the displayList with display info that may help to understand a PathFinderFailure (mainly propag...
Indicates that the refiner is done, but the path has not yet been clamped to the navMesh.
Definition: basebestgraphvertexpathfinderquery.h:31
Indicates that a computation error caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:42