#include <astarquery.h>
Runs an A-star algorithm to find a Path through the navigation data (NavMesh & NavGraph) from a starting point to a destination, refines the path found, and fills an object of type Path.
The template argument must be a class that have at least these three static functions :
The template argument must also have to define a type CanEnterNavTagMode with typedef as follow, depending whether or not you have one-way navTag transition :
or
If you are using UseCanEnterNavTag, you also have to implement this function :
This function must tell if, at position pos, we can go from exitNavTag to enterNavTag. Please refer to the SimpleTraverseLogic class documentation for details on these functions
Note that the template argument is stored in value within this class.
The propagation of the AStarQuery is bound to 2d oriented bounding box computed by inflating the segment going from startPos to destPos by a boxExtent that can be modified by calling the SetPropagationBoxExtent method. Note that bounds are only in 2D.
Inherits Kaim::BaseAStarQuery.
Public Types | |
enum | PathFinderResult { PathFinderNotInitialized, PathFinderNotComputed, PathFinderUnderProcess, PathFinderSuccess, PathFinderFailure, PathFinderFailure_NavDataChanged } |
Enumerates the possible status of a IPathFinderQuery. More... | |
Public Member Functions | |
virtual void | Advance (WorkingMemory *workingMemory) |
This function is called by the QueryQueue to process one step on the query. More... | |
virtual void | ReleaseWorkingMemoryOnCancelDuringProcess (WorkingMemory *workingMemory=nullptr) |
Called when a query is canceled in FlushCommands while its status is QueryInProcess to make sure that the WorkingMemory is left in valid state (typically, no WorkingMemory buffer should be in used after this call). More... | |
Public Attributes | |
QueryProcessStatus | m_processStatus |
Modified by the query within Advance(). Do not modify. More... | |
Ptr< IOnDone > | m_onDone |
The optional IOnDone instance to be called. Must be set manually by the user. See IOnDone. More... | |
For internal use only | |
bool | TraversalHasVisitedNavDataChanged () |
Functions | |
void | SetNavigationProfileId (KyUInt32 navigationProfileId) |
KyUInt32 | GetNavigationProfileId () const |
Public Data Members | |
KyUInt32 | m_navigationProfileId |
Vec3f | m_startPos3f |
The starting position for the Path request. More... | |
PathFinderQueryComputeChannelMode | m_computeChannelMode |
The mode toggling Channels computation. More... | |
ChannelComputerConfig | m_channelComputerConfig |
The parameter set specific to Channels computation. More... | |
FullDebug | m_fullDebug |
bool | m_doClampRawPath |
KyUInt32 | m_lastAdvanceDatabaseChangeIdx |
Ptr< Path > | m_path |
The Path found by the query. More... | |
IQuery implementation | |
virtual QueryType | GetType () const |
Get query type. More... | |
virtual void | BuildQueryBlob (BaseBlobHandler *blobHandler) |
virtual void | InitFromQueryBlob (World *world, void *blob) |
virtual Ptr< BaseBlobHandler > | CreateQueryBlobHandler () |
IPathFinderQuery implementation | |
virtual void | GetPathFinderTextResult (String &) const |
Fills the String with an explanation of the result. Use this to debug your pathfinder query. More... | |
virtual void | DisplayPropagationBounds (DisplayList &displayList) const |
Fill the displayList with display info that may help to understand a PathFinderFailure (mainly propagation bounds) More... | |
virtual PathFinderResult | GetPathFinderResult () const |
virtual const Vec3f * | GetDestination () const |
This function is virtual because not all the PathFinders have a preset destination, it may return nullptr. More... | |
BindToDatabase | |
void | BindToDatabase (Database *database) |
Binds the query with database, clears inputs and results, sets the configuration to defaults. More... | |
inputs setters | |
void | Initialize (const Vec3f &startPos, const Vec3f &destPos) |
Clears inputs and results, leaves configuration unchanged. More... | |
void | SetStartTrianglePtr (const NavTrianglePtr &startTrianglePtr) |
If no startTrianglePtr is set, it will be automatically computed during the query. More... | |
void | SetStartNavGraphEdgePtr (const NavGraphEdgePtr &startNavGraphEdgePtr, NavGraphEdgeDirection startNavGraphEdgeDirection) |
Sets start inside a NavGraphEdge. if startNavGraphEdgeDirection specifies if query can start in reverse edge if it exists. More... | |
void | SetStartNavGraphVertexPtr (const NavGraphVertexPtr &startNavGraphVertexPtr) |
Sets start to a NavGraphVertex. Optional input. More... | |
void | SetDestTrianglePtr (const NavTrianglePtr &destTrianglePtr) |
If no destTrianglePtr is set, it will be automatically computed during the query. Optional input. More... | |
void | SetDestNavGraphEdgePtr (const NavGraphEdgePtr &destNavGraphEdgePtr, NavGraphEdgeDirection destNavGraphEdgeDirection) |
Sets destination inside a NavGraphEdge. destNavGraphEdgeDirection specifies if query can start in reverse edge if it exists. More... | |
void | SetDestNavGraphVertexPtr (const NavGraphVertexPtr &destNavGraphVertexPtr) |
Sets destination to a NavGraphVertex. More... | |
configuration setters | |
void | SetTryCanGoMode (PathFinderQueryTryCanGoMode tryCanGoMode) |
void | SetPropagationBoxExtent (KyFloat32 propagationBoxExtent) |
void | SetFromOutsideNavMeshDistance (KyFloat32 fromOutsideNavMeshDistance) |
void | SetToOutsideNavMeshDistance (KyFloat32 toOutsideNavMeshDistance) |
void | SetAbstractGraphTraversalMode (PathFinderAbstractGraphTraversalMode abstractGraphTraversalMode) |
void | SetComputeChannelMode (PathFinderQueryComputeChannelMode computeChannelMode) |
void | SetChannelComputerConfig (const ChannelComputerConfig &channelComputerConfig) |
void | SetPositionSpatializationRange (const PositionSpatializationRange &positionSpatializationRange) |
void | SetNumberOfProcessedNodePerFrame (KyUInt32 numberOfProcessedNodePerFrame) |
void | SetPathClamperFlagMask (PathClamperFlagMask pathClamperFlagMask) |
results getter | |
Path * | GetPath () const |
Path * | GetAbstractPath () const |
AStarQueryResult | GetResult () const |
ChannelArrayComputerResult | GetChannelResult () const |
inputs getters | |
const Vec3f & | GetStartPos () const |
const NavTrianglePtr & | GetStartTrianglePtr () const |
const NavGraphEdgePtr & | GetStartNavGraphEdgePtr () const |
const NavGraphVertexPtr & | GetStartNavGraphVertexPtr () const |
const Vec3f & | GetDestPos () const |
const NavTrianglePtr & | GetDestTrianglePtr () const |
const NavGraphEdgePtr & | GetDestNavGraphEdgePtr () const |
const NavGraphVertexPtr & | GetDestNavGraphVertexPtr () const |
configuration getters | |
PathFinderQueryTryCanGoMode | GetTryCanGoMode () const |
KyFloat32 | GetPropagationBoxExtent () const |
KyFloat32 | GetFromOutsideNavMeshDistance () const |
KyFloat32 | GetToOutsideNavMeshDistance () const |
PathClamperFlagMask | GetPathClamperFlagMask () const |
PathFinderAbstractGraphTraversalMode | GetAbstractGraphTraversalMode () const |
PathFinderQueryComputeChannelMode | GetComputeChannelMode () const |
const ChannelComputerConfig & | GetChannelComputerConfig () const |
const PositionSpatializationRange & | GetPositionSpatializationRange () const |
KyUInt32 | GetNumberOfProcessedNodePerFrame () const |
For internal use only | |
void | ComputePathRefinerConfigInternals () |
const PathRefinerConfig & | GetPathRefinerConfig () const |
start | |
NavTrianglePtr | m_startTrianglePtr |
If no m_startTrianglePtr is set, it will be automatically computed from m_startPos3f. More... | |
NavGraphEdgePtr | m_startNavGraphEdgePtr |
if valid, query starts inside a NavGraphEdge More... | |
NavGraphEdgeDirection | m_startNavGraphEdgeDirection |
if NAVGRAPHEDGE_BIDIRECTIONAL query starts also inside m_startNavGraphEdgePtr reverse edge if it exists. More... | |
NavGraphVertexPtr | m_startNavGraphVertexPtr |
if valid, query starts at m_startNavGraphVertexPtr More... | |
destination | |
Vec3f | m_destPos3f |
The destination position. More... | |
NavTrianglePtr | m_destTrianglePtr |
If no m_destTrianglePtr is set, it will be automatically computed from m_destPos3f. More... | |
NavGraphEdgePtr | m_destNavGraphEdgePtr |
if valid, query ends inside a NavGraphEdge More... | |
NavGraphEdgeDirection | m_destNavGraphEdgeDirection |
if NAVGRAPHEDGE_BIDIRECTIONAL query ends also inside m_startNavGraphEdgePtr reverse edge if it exists. More... | |
NavGraphVertexPtr | m_destNavGraphVertexPtr |
if valid, query ends at m_startNavGraphVertexPtr More... | |
configuration | |
PathFinderQueryTryCanGoMode | m_tryCanGoMode |
default PATHFINDER_TRY_RAYCANGO_IF_NO_COST More... | |
PathRefinerConfig | m_pathRefinerConfig |
PathClamperFlagMask | m_pathClamperFlagMask |
default PathClamperFlag_ClampAll More... | |
PathFinderAbstractGraphTraversalMode | m_abstractGraphTraversalMode |
default PATHFINDER_TRAVERSE_ABSTRACT_GRAPHS More... | |
KyFloat32 | m_propagationBoxExtent |
limits propagation to the (start-dest) segment inflated by m_propagationBoxExtent. default 200.0f More... | |
computed | |
Vec3f | m_startInsidePos3f |
if m_startPos3f is outside NavMesh it is the computed inside pos in the 2d range of m_fromOutsideNavMeshDistance More... | |
Vec3f | m_destInsidePos3f |
if m_destInsidePos3f is outside NavMesh it is the computed inside pos in the 2d range of m_toOutsideNavMeshDistance More... | |
bool | m_isStartTriangleHooked |
TraversalParameters | m_traversalParams |
Ptr< CellFilter > | m_propagationCellFilter |
results | |
Ptr< Path > | m_abstractPath |
The Abstract Path found by the query. More... | |
AStarQueryResult | m_result |
Updated during processing to indicate the result of the PathFinderQueryResult query. More... | |
ChannelArrayComputerResult | m_channelResult |
IQuery Functions | |
bool | CanBeInitialized () const |
In the case of a query processed in a QueryQueue, this must be tested before initializing the query, to prevent modifying the query during the process. More... | |
bool | IsInAQueryQueue () const |
Returns true if the query is currently registered in a QueryQueue. More... | |
bool | IsSafeToReadResult () const |
Returns true if the query has been processed, is no longer in a queue, and OnDone (if there is one) has been called. More... | |
KyUInt32 | PerformQueryBlocking (WorkingMemory *workingMemory=nullptr) |
Calls Advance() untill the query is done. More... | |
void | OnDone () |
Calls m_onDone IOnDone::OnDone() if m_onDone is not null. More... | |
KyResult | SendVisualDebug () |
Sends the query to the NavigationLab. More... | |
void | SetTraverseLogicUserData (void *traverseLogicUserData) |
Sets m_traverseLogicUserData for queries that have a custom TraverseLogic, useless otherwise. More... | |
void * | GetTraverseLogicUserData () const |
Gets m_traverseLogicUserData. More... | |
For internal use only | |
static const char * | GetQueryTypeName (QueryType queryType) |
Database * | m_database |
The database on which the query will be performed. Set in Initialize(), do not directly modify. More... | |
void * | m_traverseLogicUserData |
This userData is typically passed by the Bot. More... | |
QueryQueue * | m_queue |
Updated by the QueryQueue. Do not modify. More... | |
QueryStatusInQueue | m_inQueueStatus |
Used by the QueryQueue. Do not modify. More... | |
KyUInt32 | m_queryInfoId |
|
inherited |
Enumerates the possible status of a IPathFinderQuery.
Enumerator | |
---|---|
PathFinderNotInitialized |
The IPathFinderQuery is not yet initialized. |
PathFinderNotComputed |
The IPathFinderQuery is initialized but has not been processed. |
PathFinderUnderProcess |
The IPathFinderQuery is currently under process. |
PathFinderSuccess |
The IPathFinderQuery has been completed and a Path has been found. |
PathFinderFailure |
The IPathFinderQuery has been completed but no Path has been found. |
PathFinderFailure_NavDataChanged |
The IPathFinderQuery ended prematurely due to changes into NavData. |
|
inlinevirtual |
This function is called by the QueryQueue to process one step on the query.
One call to Advance should be short (< 0.1ms as too long). It's Advance() responsibility to update m_processStatus. If the query is atomic, one call to Advance() will fully perform the query and set m_processStatus to QueryDone. If the query is time-sliced, several calls to Advance() will be needed to complete the query. the first call should set m_processStatus to Kaim::QueryInProcess and the last one to Kaim::QueryDone.
workingMemory | Sandbox memory used to perform queries. |
Implements Kaim::IQuery.
|
inherited |
Binds the query with database, clears inputs and results, sets the configuration to defaults.
|
inlineinherited |
In the case of a query processed in a QueryQueue, this must be tested before initializing the query, to prevent modifying the query during the process.
|
virtualinherited |
Fill the displayList with display info that may help to understand a PathFinderFailure (mainly propagation bounds)
Reimplemented from Kaim::IPathFinderQuery.
|
inlinevirtualinherited |
This function is virtual because not all the PathFinders have a preset destination, it may return nullptr.
Implements Kaim::IPathFinderQuery.
|
virtualinherited |
Fills the String with an explanation of the result. Use this to debug your pathfinder query.
Reimplemented from Kaim::IPathFinderQuery.
|
inlineinherited |
Gets m_traverseLogicUserData.
|
inlinevirtualinherited |
Get query type.
Implements Kaim::IQuery.
Clears inputs and results, leaves configuration unchanged.
|
inlineinherited |
Returns true if the query is currently registered in a QueryQueue.
If true, you must not push it again in QueryQueue (even the same one). If false, you must not try to cancel it from the QueryQueue.
|
inlineinherited |
Returns true if the query has been processed, is no longer in a queue, and OnDone (if there is one) has been called.
If true, it's guaranteed to be safe to read the results of this query. Will return false if the Query has been cancelled or has not yet been processed.
|
inlineinherited |
Calls m_onDone IOnDone::OnDone() if m_onDone is not null.
Called automatically by the QueryQueue during the World::Update() (in the FlushQueries() step) when this query has been completed. OnDone() is not called if the query is canceled. Note that the member m_onDone is reset to nullptr at the end of this function.
|
inherited |
|
inlinevirtual |
Called when a query is canceled in FlushCommands while its status is QueryInProcess to make sure that the WorkingMemory is left in valid state (typically, no WorkingMemory buffer should be in used after this call).
Implements Kaim::ITimeSlicedQuery.
|
inherited |
Sends the query to the NavigationLab.
Currently the implementation transform the query using a DisplayList, and the display list is shown only at the frame SendVisualDebug is called.
|
inlineinherited |
Sets destination inside a NavGraphEdge. destNavGraphEdgeDirection specifies if query can start in reverse edge if it exists.
|
inlineinherited |
Sets destination to a NavGraphVertex.
|
inlineinherited |
If no destTrianglePtr is set, it will be automatically computed during the query. Optional input.
|
inlineinherited |
Sets start inside a NavGraphEdge. if startNavGraphEdgeDirection specifies if query can start in reverse edge if it exists.
|
inlineinherited |
Sets start to a NavGraphVertex. Optional input.
|
inlineinherited |
If no startTrianglePtr is set, it will be automatically computed during the query.
|
inlineinherited |
Sets m_traverseLogicUserData for queries that have a custom TraverseLogic, useless otherwise.
|
protectedinherited |
default PATHFINDER_TRAVERSE_ABSTRACT_GRAPHS
|
protectedinherited |
The Abstract Path found by the query.
|
inherited |
The parameter set specific to Channels computation.
|
inherited |
The mode toggling Channels computation.
|
inherited |
The database on which the query will be performed. Set in Initialize(), do not directly modify.
|
protectedinherited |
if m_destInsidePos3f is outside NavMesh it is the computed inside pos in the 2d range of m_toOutsideNavMeshDistance
|
protectedinherited |
if NAVGRAPHEDGE_BIDIRECTIONAL query ends also inside m_startNavGraphEdgePtr reverse edge if it exists.
|
protectedinherited |
if valid, query ends inside a NavGraphEdge
|
protectedinherited |
if valid, query ends at m_startNavGraphVertexPtr
|
protectedinherited |
The destination position.
|
protectedinherited |
If no m_destTrianglePtr is set, it will be automatically computed from m_destPos3f.
|
inherited |
Used by the QueryQueue. Do not modify.
|
inherited |
|
protectedinherited |
default PathClamperFlag_ClampAll
|
inherited |
Modified by the query within Advance(). Do not modify.
Before reading m_processStatus, always ensure IsInAQueryQueue() returns false.
|
protectedinherited |
limits propagation to the (start-dest) segment inflated by m_propagationBoxExtent. default 200.0f
|
inherited |
Updated by the QueryQueue. Do not modify.
|
protectedinherited |
Updated during processing to indicate the result of the PathFinderQueryResult query.
|
protectedinherited |
if m_startPos3f is outside NavMesh it is the computed inside pos in the 2d range of m_fromOutsideNavMeshDistance
|
protectedinherited |
if NAVGRAPHEDGE_BIDIRECTIONAL query starts also inside m_startNavGraphEdgePtr reverse edge if it exists.
|
protectedinherited |
if valid, query starts inside a NavGraphEdge
|
protectedinherited |
if valid, query starts at m_startNavGraphVertexPtr
|
protectedinherited |
If no m_startTrianglePtr is set, it will be automatically computed from m_startPos3f.
|
inherited |
This userData is typically passed by the Bot.
|
protectedinherited |
default PATHFINDER_TRY_RAYCANGO_IF_NO_COST