![]() |
XII Release 0.1.0
|
Implements a directed breadth-first search through a graph (A*). More...
#include <GraphSearch.h>
Classes | |
struct | PathResultData |
FindPath() and FindClosest() return an array of these objects as the path result. More... | |
Public Types | |
typedef bool(* | IsSearchedObjectCallback) (xiiInt64 iStartNodeIndex, const PathStateType &StartState) |
Used by FindClosest() to query whether the currently visited node fulfills the termination criteria. | |
Public Member Functions | |
void | SetPathStateGenerator (xiiPathStateGenerator< PathStateType > *pStateGenerator) |
Sets the xiiPathStateGenerator that should be used by this xiiPathSearch object. | |
xiiResult | FindPath (xiiInt64 iStartNodeIndex, const PathStateType &StartState, xiiInt64 iTargetNodeIndex, xiiDeque< PathResultData > &out_Path, float fMaxPathCost=xiiMath::Infinity< float >()) |
Searches for a path that starts at the graph node iStartNodeIndex with the start state StartState and shall terminate when the graph node iTargetNodeIndex was reached. | |
xiiResult | FindClosest (xiiInt64 iStartNodeIndex, const PathStateType &StartState, IsSearchedObjectCallback Callback, xiiDeque< PathResultData > &out_Path, float fMaxPathCost=xiiMath::Infinity< float >()) |
Searches for a path that starts at the graph node iStartNodeIndex with the start state StartState and shall terminate when a graph node is reached for which Callback return true. | |
void | AddPathNode (xiiInt64 iNodeIndex, const PathStateType &NewState) |
Needs to be called by the used xiiPathStateGenerator to add nodes to evaluate. | |
Implements a directed breadth-first search through a graph (A*).
You can search for a path to a specific location using FindPath() or to the closest node that fulfills some arbitrary criteria using FindClosest().
PathStateType must be derived from xiiPathState and can be used for keeping track of certain state along a path and to modify the path search dynamically.
xiiResult xiiPathSearch< PathStateType >::FindClosest | ( | xiiInt64 | iStartNodeIndex, |
const PathStateType & | StartState, | ||
IsSearchedObjectCallback | Callback, | ||
xiiDeque< PathResultData > & | out_Path, | ||
float | fMaxPathCost = xiiMath::Infinity<float>() ) |
Searches for a path that starts at the graph node iStartNodeIndex with the start state StartState and shall terminate when a graph node is reached for which Callback return true.
Returns XII_FAILURE if no path could be found. Returns the path result as a list of PathResultData objects in out_Path.
The path search is stopped (and thus fails) if the path reaches costs of fMaxPathCost or higher.
xiiResult xiiPathSearch< PathStateType >::FindPath | ( | xiiInt64 | iStartNodeIndex, |
const PathStateType & | StartState, | ||
xiiInt64 | iTargetNodeIndex, | ||
xiiDeque< PathResultData > & | out_Path, | ||
float | fMaxPathCost = xiiMath::Infinity<float>() ) |
Searches for a path that starts at the graph node iStartNodeIndex with the start state StartState and shall terminate when the graph node iTargetNodeIndex was reached.
Returns XII_FAILURE if no path could be found. Returns the path result as a list of PathResultData objects in out_Path.
The path search is stopped (and thus fails) if the path reaches costs of fMaxPathCost or higher.