PathEngine home previous: iAgent::findShortestPathTo()next: iAgent::firstCollisionTo()
Contents, API Reference, Interfaces, iAgent, findShortestPathTo_WithQueryCallBack

iAgent::findShortestPathTo_WithQueryCallBack()

Description

Finds the shortest path from the agent's current position to a specified target position.
(This version supports passing in a callback object to enable the query to be aborted early.)

Syntax

std::unique_ptr<iPath> findShortestPathTo_WithQueryCallBack(const iCollisionContext* context, const cPosition& target, iQueryCallBack* queryCallBack) const

Parameters

context The state of dynamic collision that will apply for this query.
An empty context can be specified by passing nullptr for this argument.
Note that the agent is not considered to obstruct itself even if included in this context.
target The target position for pathfinding. This position must be a valid position on the agent's mesh.
queryCallBack A pointer to a valid implementation of the iQueryCallBack interface, or else null.

Requirements

Requires that the agent is moveable and that pathfinding preprocess has been generated on the agent's mesh for the agent's collision shape.

The start point for pathfinding (i.e. the agent's current position) must not be obstructed by the base mesh or burnt-in obstacles.

Return Value

A newly created Interface iPath object, if a path can be found.
Otherwise a zero pointer is returned.

Remarks

Queries for which the target position is obstructed can be a lot more expensive, so if the target position is potentially obstructed then it is a good idea to call iAgent::testCollisionAt() for the target position first.
If the target position is obstructed then you know that the query will fail.
This check is not performed internally to avoid adding overhead in cases where the target position is known in advance to be unobstructed.

Refer to Aborting Pathfinding Early for details about using the query callback mechanism.
Note that if the search is aborted by the query callback then the path returned will not reach the goal.

See Also

iMesh::findShortestPath_WithQueryCallBack()

C# Mapping

Path findShortestPathTo_WithQueryCallBack(CollisionContext context, PathEngine.Position target, QueryCallBack queryCallBack);

Java Mapping

Path findShortestPathTo_WithQueryCallBack(CollisionContext context, Position target, QueryCallBack queryCallBack);

Documentation for PathEngine release 6.04 - Copyright © 2002-2024 PathEnginenext: iAgent::firstCollisionTo()