gwnavruntime/queries/bestgraphvertexpathfinderquery.h Source File

bestgraphvertexpathfinderquery.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_BestGraphVertexPathFinderQuery_H
10 #define Navigation_BestGraphVertexPathFinderQuery_H
11 
16 
17 
18 namespace Kaim
19 {
20 
21 class PathFinderQueryUtils;
22 
23 enum OnGraphVertexVisitedResult
24 {
25  OnGraphVertexVisited_IgnoreVertex_GoOn,
26  OnGraphVertexVisited_IgnoreVertex_StopWithBestSoFar,
27  OnGraphVertexVisited_StopOnThisVertex,
28  OnGraphVertexVisited_VertexIsTheBestSoFar_GoOn,
29  OnGraphVertexVisited_NeedToCheckRefinePathToThisVertex
30 };
31 
32 enum OnPathToGraphVertexComputedResult
33 {
34  OnPathToGraphVertexComputed_IgnoreVertex_GoOn,
35  OnPathToGraphVertexComputed_IgnoreVertex_StopWithBestSoFar,
36  OnPathToGraphVertexComputed_StopOnThisVertex,
37  OnPathToGraphVertexComputed_VertexIsTheBestSoFar_GoOn,
38 };
39 
57 
58 template<class VertexFinderLogic>
59 class BestGraphVertexPathFinderQuery : public BaseBestGraphVertexPathFinderQuery
60 {
61 public:
62 
63  // ---------------------------------- Public Member Functions ----------------------------------
64 
67 
68  // ---------------------------------- Functions to set up the query ----------------------------------
69 
73  void BindToDatabase(Database* database);
74 
79  void Initialize(const Vec3f& startPos);
80 
81  // ---------------------------------- write accessors for query inputs ----------------------------------
82 
86  void SetStartTrianglePtr(const NavTrianglePtr& startTrianglePtr);
87 
91  void SetStartNavGraphEdgePtr(const NavGraphEdgePtr& startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode);
92 
97  void SetStartNavGraphVertexPtr(const NavGraphVertexPtr& startNavGraphVertexPtr);
98 
99  // ---------------------------------- write accessors for query parameters ----------------------------------
100 
103  void SetFromOutsideNavMeshDistance(KyFloat32 fromOutsideNavMeshDistance);
104 
107  void SetPropagationRadius(KyFloat32 propagationRadius);
108 
111  void SetPositionSpatializationRange(const PositionSpatializationRange& positionSpatializationRange);
112 
116 
119  void SetChannelComputerConfig(const ChannelComputerConfig& channelComputerConfig);
120 
123  void SetNumberOfProcessedNodePerFrame(KyUInt32 numberOfProcessedNodePerFrame);
124 
125  // ---------------------------------- Query framework functions ----------------------------------
126 
129  virtual void Advance(WorkingMemory* workingMemory);
130 
131  virtual void ReleaseWorkingMemoryOnCancelDuringProcess(WorkingMemory* workingMemory = KY_NULL);
132 
133  // ---------------------------------- Accessors ----------------------------------
134  BestGraphVertexPathFinderQueryResult GetResult() const;
135 
136  KyFloat32 GetFromOutsideNavMeshDistance() const;
137  KyFloat32 GetPropagationRadius() const;
138  const Vec3f& GetStartPos() const;
139  const NavTrianglePtr& GetStartTrianglePtr() const;
140  const NavGraphEdgePtr& GetStartNavGraphEdgePtr() const;
141  const NavGraphVertexPtr& GetStartNavGraphVertexPtr() const;
142  Path* GetPath() const;
143  KyUInt32 GetNumberOfProcessedNodePerFrame() const;
144 
145  const PositionSpatializationRange& GetPositionSpatializationRange() const;
146 
147  void ComputePathRefinerConfigInternals();
148  const PathRefinerConfig& GetPathRefinerConfig() const;
149 
150 
151 public: //Internal
152  bool HasNavDataChanged();
153 
154 protected:
155  void SetFinish(WorkingMemory* workingMemory);
156  KyResult ComputeStartGraphEdgeOrGraphVertexOrTriangle(PathFinderQueryUtils& queryUtils);
157  KyResult ComputeStartTriangle(PathFinderQueryUtils& queryUtils);
158 
159  void SetResult(BestGraphVertexPathFinderQueryResult result);
160  KyResult ComputeDestTriangle(PathFinderQueryUtils& queryUtils);
161  KyResult InitDestinationNode();
162  KyResult CheckNavDataChange(WorkingMemory* workingMemory);
163  KyResult InitTraversalFromStartNode(PathFinderQueryUtils& queryUtils);
164  KyResult InitializeContextAndStartNode(PathFinderQueryUtils& queryUtils);
165 
166 protected:
167 
168  class TraversalCustomizer
169  {
170  public:
171  typedef VertexFinderLogic TLogic;
172 
173  TraversalCustomizer() : m_traverseLogicUserData(KY_NULL) {}
174 
175  bool CanTraverse(const NavTriangleRawPtr& triangleRawPtr, KyFloat32* costMultiplier);
176  bool CanTraverse(const NavGraphEdgeRawPtr& edgeRawPtr, KyFloat32* costMultiplier);
177 
178  bool CanEnterNavTag(const NavTag& exitNavTag, const NavTag& enterNavTag, const Vec3f& pos);
179  KyFloat32 GetHeuristicFromNodePosition(const Vec3f& nodePosition);
180 
181 // KyFloat32 GetNavMeshEdgeCost(const Vec3f& start, const Vec3f& end, const NavTag& navTag);
182  bool ShouldVisitNode(AStarTraversalContext* astarContext, AStarNodeIndex nodeIndex);
183  bool IsNodeOutsidePropagationBounds(AStarTraversalContext* astarContext, AStarNodeIndex nodeIndex);
184  bool ShouldOpenHalfEdgeNode(const NavHalfEdgeRawPtr& halfEdge, NavHalfEdgeRawPtr& pairHalfEdgeOfNewNode);
185  bool ShouldOpenGraphVertexNode(const NavGraphVertexRawPtr& navGraphVertexRawPtr);
186  bool ShouldOpenAbstractGraphNode(const AbstractGraphNodeRawPtr& abstractGraphNodeRawPtr);
187  bool ShouldOpenNavTriangleUnderAbstractGraphNode(const AbstractGraphNodeRawPtr& abstractGraphNodeRawPtr);
188  Vec3f ComputeNodePositionOnHalfEdge(AStarTraversalContext* aStarTraversalContext, const Vec3f& startPosOfEdge,
189  const Vec3f& endPosOfEdge, AStarNodeIndex predecessorNodeIndex);
190  KyResult OnNavTriangleExplored(AStarTraversalContext* aStarTraversalContext, const NavTriangleRawPtr& navTriangleRawPtr, AStarNodeIndex currentNodeIndex);
191  KyResult OnNavGraphEdgeExplored(AStarTraversalContext* aStarTraversalContext, const NavGraphEdgeRawPtr& navGraphEdgeRawPtr, AStarNodeIndex currentNodeIndex);
192  void* GetTraverseLogicUserData() const { return m_traverseLogicUserData; }
193 
194  // propagationBounds
195  Vec3f m_startPos;
196  KyFloat32 m_maxRadius;
198  };
199 
200  AStarTraversal<TraversalCustomizer> m_traversal;
201 };
202 
203 }
204 
206 
207 #endif //Navigation_BestGraphVertexPathFinderQuery_H
208 
This query propagates outward through the NavMesh from the starting position.
Definition: bestgraphvertexpathfinderquery.h:62
PathFinderQueryComputeChannelMode
This enum tells if the PathFinderQuery should compute Channels around path sections laying on the Nav...
Definition: ipathfinderquery.h:28
virtual void Advance(WorkingMemory *workingMemory)
Performs a single iteration of the PathFinder.
Definition: bestgraphvertexpathfinderquery.inl:174
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
void BindToDatabase(Database *database)
Binds the query with the specified Database, clears all the inputs and outputs and sets all other par...
Definition: bestgraphvertexpathfinderquery.inl:33
void SetStartTrianglePtr(const NavTrianglePtr &startTrianglePtr)
The NavMesh triangle that corresponds to m_startPos3f.
Definition: bestgraphvertexpathfinderquery.inl:45
void SetPropagationRadius(KyFloat32 propagationRadius)
Write accessor for m_propagationRadius.
Definition: bestgraphvertexpathfinderquery.inl:70
void SetNumberOfProcessedNodePerFrame(KyUInt32 numberOfProcessedNodePerFrame)
Write accessor for TraversalParams::m_numberOfVisitedNodePerFrame.
Definition: bestgraphvertexpathfinderquery.inl:88
Class that aggregates parameters that allow to configure the channel computation of a Bot...
Definition: channelcomputerconfig.h:76
This class is an helper used internaly by the PathFinder Queries to factorize Code.
Definition: pathfinderqueryutils.h:37
#define KY_NULL
Null value.
Definition: types.h:247
Each instance of this class uniquely identifies a single NavGraphEdge in a NavGraph.
Definition: navgraphedgerawptr.h:33
void SetPositionSpatializationRange(const PositionSpatializationRange &positionSpatializationRange)
Write accessor for TraversalParams::m_positionSpatializationRange.
Definition: bestgraphvertexpathfinderquery.inl:60
void SetComputeChannelMode(PathFinderQueryComputeChannelMode computeChannelMode)
Write accessor for m_computeChannelMode.
Definition: bestgraphvertexpathfinderquery.inl:76
void SetChannelComputerConfig(const ChannelComputerConfig &channelComputerConfig)
Write accessor for m_channelComputerConfig.
Definition: bestgraphvertexpathfinderquery.inl:82
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
Definition: gamekitcrowddispersion.h:20
void SetStartNavGraphEdgePtr(const NavGraphEdgePtr &startNavGraphEdgePtr, NavGraphEdgeDirection navGraphEdgePathfindMode)
Optional NavGraph edge you want the start position must be considered to lie on.
Definition: bestgraphvertexpathfinderquery.inl:50
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexptr.h:22
void SetFromOutsideNavMeshDistance(KyFloat32 fromOutsideNavMeshDistance)
Write accessor for TraversalParams::m_fromOutsideNavMeshDistance.
Definition: bestgraphvertexpathfinderquery.inl:65
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtrianglerawptr.h:30
void SetStartNavGraphVertexPtr(const NavGraphVertexPtr &startNavGraphVertexPtr)
Optional NavGraph Vertex you want the start position must be considered to be on. ...
Definition: bestgraphvertexpathfinderquery.inl:55
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
virtual void ReleaseWorkingMemoryOnCancelDuringProcess(WorkingMemory *workingMemory=0)
Called when a query is canceled in FlushCommands while its status is QueryInProcess to make sure that...
Definition: bestgraphvertexpathfinderquery.inl:163
void * m_traverseLogicUserData
This userData is typically passed by the Bot.
Definition: iquery.h:278
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
Each instance of this class uniquely identifies a singleNavHalfEdge in a NavFloor.
Definition: navhalfedgerawptr.h:34
Each instance of this class uniquely identifies a single NavGraphVertex in a NavGraph.
Definition: navgraphvertexrawptr.h:36
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