PathEngine home previous: Performing Collision Queries without Preprocessnext: Limiting the Scope for Pathfinding
Contents, Programmers Guide, Applying the SDK, Pathfinding Queries

Pathfinding Queries

Supplying a context

Each query accepts a collision context argument.
This controls the set of obstacles to be 'included' for the query.

Calling against the mesh or agent interfaces

In general, each query can be invoked on either the Interface iMesh or the Interface iAgent interface.
The iAgent methods supply arguments corresponding to the position and shape of the agent on which the method is called, and ensure that the agent itself is not treated as an obstruction.

The queries

Shortest path

iMesh::findShortestPath() and iAgent::findShortestPathTo() provide the fundamental pathfinding query for a path from a known start point to a known goal.

iMesh::findShortestPath_WithQueryCallBack() and iAgent::findShortestPathTo_WithQueryCallBack() extend this with the possibility to restrict pathfinding scope or number of iterations.
(See Limiting the Scope for Pathfinding and Aborting Pathfinding Early)

iMesh::findShortestPath_MultipleStartPositions() searches for the shortest path where multiple potential start positions could be used (e.g. multiple agents could potentially be selected to attack a single target).
Note that this shortest path query version can then also be used for implementing search to multiple targets, in cases where paths are reversible, by calling iMesh::constructPath_Reversed() to reverse the path result.

Path away

iMesh::findPathAway() and iAgent::findPathAway() both find the shortest path out of a region around a specified point.
This can be used as the basis for a 'run away' behaviour.

iMesh::findPathAway_WithQueryCallBack() and iAgent::findPathAway_WithQueryCallBack() extend this with the possibility to restrict pathfinding scope or number of iterations.
(See Limiting the Scope for Pathfinding and Aborting Pathfinding Early)

Closest unobstructed point

iMesh::findClosestUnobstructedPosition() and iAgent::findClosestUnobstructedPosition() find the closest unobstructed position to a specified target position.

This query is essential for pathfinding to or from positions that may be outside unobstructed space for a pathfinding agent, for example in the case where large agents chase smaller agents, or when agents move under the control of an external collision system.

And this can also be very useful as a component for constructing quite a wide variety of different movement based behaviours, for example attack target slot generation when multiple agents are assigned to attack a target and should not overlap, finding 'escape' positions outside of arbitrary danger shapes, and so on.

Note that this query does not actually require full pathfind preprocess generation, only collision preprocess is required.


Documentation for PathEngine release 5.29 - Copyright © 2002-2012 PathEnginenext: Limiting the Scope for Pathfinding