gwnavruntime/queries/utils/basebestgraphvertexpathfinderquery.h Source File

basebestgraphvertexpathfinderquery.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 
13 
14 namespace Kaim
15 {
16 
19 {
22 
32 
42 
44 };
45 
48 {
49 public:
50  static QueryType GetStaticType() { return TypeBestGraphVertexPathFinderQuery; }
51  virtual QueryType GetType() const { return TypeBestGraphVertexPathFinderQuery; }
52  virtual void BuildQueryBlob(BaseBlobHandler* blobHandler);
53  virtual void InitFromQueryBlob(World* world, void* blob);
54  virtual Ptr<BaseBlobHandler> CreateQueryBlobHandler() { return CreateStaticQueryBlobHandler(); }
55  static Ptr<BaseBlobHandler> CreateStaticQueryBlobHandler();
56 
57  virtual void GetPathFinderTextResult(String&) const;
58  virtual void DisplayPropagationBounds(DisplayList& displayList) const;
59  virtual PathFinderResult GetPathFinderResult() const;
60  virtual const Vec3f* GetDestination() const { return nullptr; }
61 
62  BestGraphVertexPathFinderQueryResult GetResult() const { return m_result; }
63  KyFloat32 GetPropagationRadius() const { return m_propagationRadius; }
64  KyFloat32 GetFromOutsideNavMeshDistance() const { return m_traversalParams.m_fromOutsideNavMeshDistance; }
65  KyFloat32 GetToOutsideNavMeshDistance() const { return m_traversalParams.m_toOutsideNavMeshDistance; }
66  const Vec3f& GetStartPos() const { return IPathFinderQuery::GetStartPos(); }
67  const NavTrianglePtr& GetStartTrianglePtr() const { return m_startTrianglePtr; }
68  const NavGraphEdgePtr& GetStartNavGraphEdgePtr() const { return m_startNavGraphEdgePtr; }
69  const NavGraphVertexPtr& GetStartNavGraphVertexPtr() const { return m_startNavGraphVertexPtr; }
70  Path* GetPath() const { return m_path; }
71  KyUInt32 GetNumberOfProcessedNodePerFrame() const { return m_traversalParams.m_numberOfVisitedNodePerAdvance; }
72 
73  const PositionSpatializationRange& GetPositionSpatializationRange() const { return m_traversalParams.m_positionSpatializationRange; }
74 
75  void ComputePathRefinerConfigInternals() { m_pathRefinerConfig.ComputeInternals();}
76  const PathRefinerConfig& GetPathRefinerConfig() const { return m_pathRefinerConfig; }
77 
78  void SetPathClamperFlagMask(PathClamperFlagMask pathClamperFlagMask) { m_pathClamperFlagMask = pathClamperFlagMask; }
79 
80  void BindToDatabase(Database* database);
81  void Initialize(const Vec3f& startPos);
82  void SetStartTrianglePtr(const NavTrianglePtr& startTrianglePtr) { m_startTrianglePtr = startTrianglePtr; }
83  void SetStartNavGraphEdgePtr(const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode);
84  void SetStartNavGraphVertexPtr(const NavGraphVertexPtr& startNavGraphVertexPtr);
85 
86  void SetComputeChannelMode(PathFinderQueryComputeChannelMode mode) { m_computeChannelMode = mode; }
87  void SetChannelComputerConfig(const ChannelComputerConfig& config) { m_channelComputerConfig = config; }
88  void SetPropagationRadius(KyFloat32 propagationRadius) { m_propagationRadius = propagationRadius; }
89  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange) { m_traversalParams.m_positionSpatializationRange = positionSpatializationRange; }
90  void SetFromOutsideNavMeshDistance(KyFloat32 fromOutsideNavMeshDistance) { m_traversalParams.m_fromOutsideNavMeshDistance = fromOutsideNavMeshDistance; }
91  void SetToOutsideNavMeshDistance(KyFloat32 toOutsideNavMeshDistance) { m_traversalParams.m_toOutsideNavMeshDistance = toOutsideNavMeshDistance; }
92  void SetNumberOfProcessedNodePerFrame(KyUInt32 numberOfProcessedNodePerFrame) { m_traversalParams.m_numberOfVisitedNodePerAdvance = numberOfProcessedNodePerFrame; }
93  void SetResult(BestGraphVertexPathFinderQueryResult result) { m_result = result; }
94 
95 protected:
96  BaseBestGraphVertexPathFinderQuery();
97  virtual ~BaseBestGraphVertexPathFinderQuery() {}
98 
99 protected:
100  // start
103  NavGraphEdgeDirection m_startNavGraphEdgeDirection;
105 
106  // configuration
107  PathRefinerConfig m_pathRefinerConfig;
108  PathClamperFlagMask m_pathClamperFlagMask;
109  KyFloat32 m_propagationRadius; // the propagation is limited to a 2d circle centered in startPos and with m_propagationRadius as radius
110 
111  // computed
112  Vec3f m_startInsidePos3f; // if #m_startPos3f is slightly outside and we hook on the NavMesh, it is the computed inside pos, else it is equal to #m_startPos3f.
113  TraversalParameters m_traversalParams;
114  NavGraphVertexRawPtr m_currentVertex;
115  AStarNodeIndex m_currentVertexNodeIdx;
116  NavGraphVertexRawPtr m_bestVertex; // the best Vertex found so far.
117  AStarNodeIndex m_bestVertexNodeIdx;
118  Ptr<Path> m_rememberBestPathSoFar;
119 
120  // results
122 };
123 
124 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetStartNavGraphEdgePtr(const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode)
125 {
126  m_startNavGraphEdgePtr = startNavGraphEdgePtr;
127  m_startNavGraphEdgeDirection = navGraphEdgePathfindMode;
128  KY_LOG_WARNING_IF(m_startTrianglePtr.IsValid(), ("You are setting a start NavGraphEdgePtr whereas a start NavTrianglePtr was set too."));
129  KY_LOG_WARNING_IF(m_startNavGraphVertexPtr.IsValid(), ("You are setting a start NavGraphEdgePtr whereas a start NavGraphVertexPtr was set too."));
132 }
133 
134 KY_INLINE void BaseBestGraphVertexPathFinderQuery::SetStartNavGraphVertexPtr(const NavGraphVertexPtr& startNavGraphVertexPtr)
135 {
136  m_startNavGraphVertexPtr = startNavGraphVertexPtr;
137  KY_LOG_WARNING_IF(m_startTrianglePtr.IsValid(), ("You are setting a start NavGraphVertexPtr whereas a start NavTrianglePtr was set too."));
138  KY_LOG_WARNING_IF(m_startNavGraphEdgePtr.IsValid(), ("You are setting a start NavGraphVertexPtr whereas a start NavGraphEdgePtr was set too."));
141 }
142 }
143 
ChannelComputerConfig m_channelComputerConfig
The parameter set specific to Channels computation.
Definition: ipathfinderquery.h:86
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:123
void Invalidate()
Invalidates this object.
Definition: navtriangleptr.h:125
Base class for all pathfinder queries.
Definition: ipathfinderquery.h:34
bool IsValid() const
Returns true if this object refers to a valid NavGraphVertex: i.e. a NavGraphVertex in a validNavGrap...
Definition: navgraphvertexptr.h:100
PathFinderQueryComputeChannelMode
This enum tells if the PathFinderQuery should compute Channels around path sections laying on the Nav...
Definition: ipathfinderquery.h:25
NavGraphEdgePtr m_startNavGraphEdgePtr
if valid, propagation start using the m_startNavGraphEdgePtr
Definition: basebestgraphvertexpathfinderquery.h:102
Base class for BestGraphVertexPathFinderQuery.
Definition: basebestgraphvertexpathfinderquery.h:47
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Indicates that the input channelComputerConfig is invalid.
Definition: basebestgraphvertexpathfinderquery.h:39
PathClamperFlag
These flags determine if some specific positions must have their altitude clamped on NavMesh...
Definition: pathclamperflag.h:15
void Invalidate()
Invalidates this object.
Definition: navgraphvertexptr.h:101
Indicates the query has not yet been initialized.
Definition: basebestgraphvertexpathfinderquery.h:20
Indicates the query has not yet been launched.
Definition: basebestgraphvertexpathfinderquery.h:21
void Invalidate()
Invalidates this object.
Definition: navgraphedgeptr.h:116
Indicates that the astar traversal algorithm has been launched, but has not yet completed.
Definition: basebestgraphvertexpathfinderquery.h:23
Indicates that insufficient working memory caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:37
This class is a runtime container for Autodesk Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:52
Ptr< Path > m_path
The Path found by the query.
Definition: ipathfinderquery.h:94
Indicates that the computation has been canceled.
Definition: basebestgraphvertexpathfinderquery.h:41
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
An internal class that stores parameters used to control the propagation of traversals.
Definition: traversalparams.h:18
PathFinderQueryComputeChannelMode m_computeChannelMode
The mode toggling Channels computation.
Definition: ipathfinderquery.h:85
Indicates that the refiner is done, the channel is going to be initialized.
Definition: basebestgraphvertexpathfinderquery.h:30
QueryType
Enumerates all the type of query.
Definition: iquery.h:25
NavGraphEdgeDirection m_startNavGraphEdgeDirection
if NAVGRAPHEDGE_BIDIRECTIONAL propagation uses m_startNavGraphEdgePtr reverse edge if it exists...
Definition: basebestgraphvertexpathfinderquery.h:103
Indicates that the refining process is being initialized.
Definition: basebestgraphvertexpathfinderquery.h:25
Indicates that the refined path is being clamped to navMesh according to the altitude tolerance...
Definition: basebestgraphvertexpathfinderquery.h:28
NavTrianglePtr m_startTrianglePtr
The NavMesh triangle that corresponds to m_startPos3f. If not valid, it will be computed.
Definition: basebestgraphvertexpathfinderquery.h:101
NavGraphVertexPtr m_startNavGraphVertexPtr
if valid, propagation start using the m_startNavGraphVertexPtr
Definition: basebestgraphvertexpathfinderquery.h:104
BestGraphVertexPathFinderQueryResult m_result
Updated during processing to indicate the result of the PathFinderQueryResult query.
Definition: basebestgraphvertexpathfinderquery.h:121
virtual QueryType GetType() const
Get query type.
Definition: basebestgraphvertexpathfinderquery.h:51
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that the clamping algorithm has completed, but the path has not yet been built...
Definition: basebestgraphvertexpathfinderquery.h:29
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexptr.h:17
Indicates that the query has not yet been initialized.
Definition: iquery.h:295
virtual void DisplayPropagationBounds(DisplayList &displayList) const
Fill the displayList with display info that may help to understand a PathFinderFailure (mainly propag...
Definition: basebestgraphvertexpathfinderquery.cpp:229
Indicates that the NavTag at the starting point is forbidden.
Definition: basebestgraphvertexpathfinderquery.h:34
PathFinderResult
Enumerates the possible status of a IPathFinderQuery.
Definition: ipathfinderquery.h:38
Indicates that a path has been found between the start and destination.
Definition: basebestgraphvertexpathfinderquery.h:43
virtual const Vec3f * GetDestination() const
This function is virtual because not all the PathFinders have a preset destination, it may return nullptr.
Definition: basebestgraphvertexpathfinderquery.h:60
Indicates that a path could not be found between the start and destination points.
Definition: basebestgraphvertexpathfinderquery.h:35
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
Indicates that the channel is initialized, the channel is being computed.
Definition: basebestgraphvertexpathfinderquery.h:31
Indicates that a computation error caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:40
bool IsValid() const
Returns true if this object refers to a valid NavGraphEdge: i.e. a NavGraphEdge in a valid NavGraph...
Definition: navgraphedgeptr.h:115
Indicates that the astar traversal algorithm is finished, and that the path found is ready to be refi...
Definition: basebestgraphvertexpathfinderquery.h:24
Indicates that the query has not yet been launched.
Definition: iquery.h:296
PositionSpatializationRange m_positionSpatializationRange
The altitude range used to find NavMesh triangles that correspond to the start and destination points...
Definition: traversalparams.h:46
Each instance of this class uniquely identifies a single and mono-directionnal NavGraphEdge in a NavG...
Definition: navgraphedgeptr.h:20
BestGraphVertexPathFinderQueryResult
Enumerates the possible results of an BestGraphVertexPathFinderQuery.
Definition: basebestgraphvertexpathfinderquery.h:18
Indicates that the path found is being refined.
Definition: basebestgraphvertexpathfinderquery.h:26
Indicates that the query has stopped and must be relaunched because of a change in the NavData...
Definition: basebestgraphvertexpathfinderquery.h:36
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexrawptr.h:27
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basebestgraphvertexpathfinderquery.h:33
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16
virtual void GetPathFinderTextResult(String &) const
Fills the String with an explanation of the result. Use this to debug your pathfinder query...
Definition: basebestgraphvertexpathfinderquery.cpp:146
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
Indicates that the refiner is done, but the path has not yet been clamped to the navMesh.
Definition: basebestgraphvertexpathfinderquery.h:27
Indicates that a computation error caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:38