• Articles
  • Api Documentation
Show / Hide Table of Contents
  • AnyPath
    • Graphs
      • Extra
        • Line2D
        • Line3D
        • Triangle
      • HexGrid
        • HexGrid
        • HexGrid.Enumerator
        • HexGridCell
        • HexGridHeuristicProvider
        • HexGridType
      • Line
        • ClosestLineLocationPredicate
        • LineGraph
        • LineGraph.Edge
        • LineGraph.Enumerator
        • LineGraphBuilder
        • LineGraphBuilder.ProtoEdge
        • LineGraphDrawer
        • LineGraphHeuristic
        • LineGraphLocation
        • LineGraphPopulator
        • LineGraphProcessor
        • LineGraphWelder
        • SceneGraph
          • LineGraphNode
          • LineSceneGraph
          • LineSceneGraphEdge
          • SceneGraphNodeEditor
      • NavMesh
        • ClosestNavMeshLocationPredicate
        • CornerAndNormal
        • IUnrolledNavMeshGraphPortal
        • NavMeshGraph
        • NavMeshGraph.EnterCostAndFlags
        • NavMeshGraph.Enumerator
        • NavMeshGraphCorners
        • NavMeshGraphCorners3D
        • NavMeshGraphHeuristic
        • NavMeshGraphLocation
        • NavMeshGraphUnroller
        • NavMeshLineBitmaskMod
        • NavMeshLineMod
        • NavMeshPlaneBitmaskMod
        • NavMeshPlaneMod
        • NavMeshPopulator
        • NavMeshWelder
        • SSFA
        • UnrolledNavMeshGraphPortal
      • Node
        • NodeGraph
        • NodeGraphNode
      • PlatformerGraph
        • ClosestPlatformerGraphLocationPredicate
        • PlatformerGraph
        • PlatformerGraph.Enumerator
        • PlatformerGraphBuilder
        • PlatformerGraphBuilder.ProtoEdge
        • PlatformerGraphDrawer
        • PlatformerGraphHeuristic
        • PlatformerGraphLocation
        • PlatformerGraphPopulator
        • PlatformerGraphProcessor
        • PlatformerGraphWelder
        • SceneGraph
          • PlatformerSceneGraph
          • PlatformerSceneGraphEdge
          • PlatformerSceneGraphNode
          • SceneGraphNodeEditor
      • SquareGrid
        • SquareGrid
        • SquareGrid.Enumerator
        • SquareGridCell
        • SquareGridHeuristicProvider
        • SquareGridHeuristicProviderEightDirectional
        • SquareGridHeuristicProviderManhattanDistance
        • SquareGridType
      • VoxelGrid
        • VoxelGrid
        • VoxelGrid.DirCost
        • VoxelGrid.Enumerator
        • VoxelGridCell
        • VoxelGridDirectionFlags
        • VoxelGridDirectionMod
        • VoxelGridHeuristicProvider
        • VoxelGridHeuristicProviderManhattanDistance
    • Managed
      • ClearFinderFlags
      • FinderExtensions
      • IFinder
      • IOptionReserver<TOption>
      • IOptionValidator<TOption>
      • ImmutableFinderException
      • ManagedDisposeExtensions
      • Results
        • DijkstraResult<TNode>
        • Eval
        • Eval<TOption>
        • MultiEvalResult
        • MultiPathResult<TSeg>
        • Path<TSeg>
        • Path<TOption, TSeg>
    • Native
      • AStarCheapestOption
      • AStarEvalOptionResult
      • AStarEvalResult
      • AStarFindOptionResult
      • AStarFindPathResult
      • AStarOption
      • AStarStops
      • AStar<TNode>
      • ComposedGraph<TGraph, TNode>
      • Edge<TNode>
      • FlagBitmask<TNode>
      • IEdgeMod<TNode>
      • IGraph<TNode>
      • IHeuristicProvider<TNode>
      • INodeFlags
      • IPathProcessor<TNode, TSeg>
      • NativeListWrapper<TSeg>
      • NoEdgeMod<TNode>
      • NoProcessing<TNode>
      • OffsetInfo
      • ReversedGraph<TNode>
      • EdgeMods
        • AdditionalAndExcludeEdges<TNode>
        • AdditionalEdges<TNode>
        • ExcludeEdges<TNode>
        • ExcludeLocations<TNode>
      • Heuristics
        • ALTCompute<TGraph, TNode>
        • ALTSerialization
        • ALT<TNode>
        • LandmarkSelection<TGraph, TNode, TEnumerator>
      • Util
        • IRefComparer<T>
        • NativeMinHeap<T, TComp>
        • NativeRefMinHeap<T, TComp>

Class LandmarkSelection<TGraph, TNode, TEnumerator>

Contains utility functions for selecting landmarks to use with ALT<TNode> heuristics. These provide a general approach to selecting landmarks.

If you know that your requests will often have the same start or goal locations, it may be benificial to manually place landmarks "behind" these locations. Strategic placement of landmarks can vastly improve the efficiency of the algorithm.

Inheritance
object
LandmarkSelection<TGraph, TNode, TEnumerator>
Namespace: AnyPath.Native.Heuristics
Assembly: AnyPath.dll
Syntax
public class LandmarkSelection<TGraph, TNode, TEnumerator> where TGraph : struct, IGraph<TNode> where TNode : unmanaged, IEquatable<TNode> where TEnumerator : struct, IEnumerator<TNode>
Type Parameters
Name Description
TGraph
TNode
TEnumerator
Remarks

All of these methods use Unity's job system internally to speed up the process.

Because of a limitation of the burst compiler, you need to explicity provide the types to this class when calling any of the static methods it contains. See https://docs.unity3d.com/Packages/com.unity.burst@1.8/manual/compilation-generic-jobs.html for more information.

Constructors

LandmarkSelection()

Declaration
public LandmarkSelection()

Methods

ScheduleSelectFarthestLandmarksDirected(ref TGraph, ref ReversedGraph<TNode>, TEnumerator, NativeArray<TNode>, JobHandle)

Schedules a job that selects a set of landmarks that are spaced apart evenly. Use this method if your graph contains directed edges. This method requires more computation than ScheduleSelectFarthestLandmarksUndirected(ref TGraph, TEnumerator, NativeArray<TNode>, JobHandle), since paths from and to every node need to be computed.

Declaration
public static JobHandle ScheduleSelectFarthestLandmarksDirected(ref TGraph graph, ref ReversedGraph<TNode> reversedGraph, TEnumerator nodeEnumerator, NativeArray<TNode> destLandmarks, JobHandle dependsOn = default)
Parameters
Type Name Description
TGraph graph

The graph to select landmarks for

ReversedGraph<TNode> reversedGraph
TEnumerator nodeEnumerator

Enumerator that yields all nodes contained in the graph

NativeArray<TNode> destLandmarks

The array to fill with the selected landmarks. The amount of landmarks that will be chosen is equal to the length of this array

JobHandle dependsOn

Optional jobhandle that must be completed before this job gets scheduled.

Returns
Type Description
JobHandle

A jobhandle for the scheduled job

Remarks

This gives better results than SelectRandomLandmarks(TEnumerator, TNode[]), but requires more processing time. It is recommended to enable burst compilation because this can take a long time for large graphs. Consider serializing your landmarks if you use a static world.

ScheduleSelectFarthestLandmarksUndirected(ref TGraph, TEnumerator, NativeArray<TNode>, JobHandle)

Schedules a job that selects a set of landmarks that are spaced apart evenly. This method is sufficient for undirected graphs and less computationally expensive than the ScheduleSelectFarthestLandmarksDirected(ref TGraph, ref ReversedGraph<TNode>, TEnumerator, NativeArray<TNode>, JobHandle) method.

Declaration
public static JobHandle ScheduleSelectFarthestLandmarksUndirected(ref TGraph graph, TEnumerator nodeEnumerator, NativeArray<TNode> destLandmarks, JobHandle dependsOn = default)
Parameters
Type Name Description
TGraph graph

The graph to select landmarks for

TEnumerator nodeEnumerator

Enumerator that yields all nodes contained in the graph

NativeArray<TNode> destLandmarks

The array to fill with the selected landmarks. The amount of landmarks that will be chosen is equal to the length of this array

JobHandle dependsOn

Optional jobhandle that must be completed before this job gets scheduled.

Returns
Type Description
JobHandle

A jobhandle for the scheduled job

Remarks

This gives better results than SelectRandomLandmarks(TEnumerator, TNode[]), but requires more processing time. It is recommended to enable burst compilation because this can take a long time for large graphs. Consider serializing your landmarks if you use a static world.

ScheduleSelectRandomLandmarks(TEnumerator, NativeArray<TNode>, JobHandle)

Schedules a job that selects a set of unique, random landmarks from a graph

Declaration
public static JobHandle ScheduleSelectRandomLandmarks(TEnumerator nodeEnumerator, NativeArray<TNode> destLandmarks, JobHandle dependsOn = default)
Parameters
Type Name Description
TEnumerator nodeEnumerator

The node enumerator of the graph. Note that this algorithm does not validate if random nodes picked from this enumerator are reachable at all.

NativeArray<TNode> destLandmarks

Array to fill with the landmarks. The length of this array determines the amount of landmarks that will be selected. If there are less nodes in the graph than the supplied array, the array will be filled with the amount of nodes available.

JobHandle dependsOn

Optional jobhandle that must be completed before this job gets scheduled.

Returns
Type Description
JobHandle

SelectFarthestLandmarkDirected(ref TGraph, ref ReversedGraph<TNode>, TEnumerator, TNode[])

Runs a job on the main thread that selects a set of landmarks that are spaced apart evenly. Use this method if your graph contains directed edges. This method requires more computation than SelectFarthestLandmarksUndirected(ref TGraph, TEnumerator, TNode[]), since paths from and to every node need to be computed.

Declaration
public static void SelectFarthestLandmarkDirected(ref TGraph graph, ref ReversedGraph<TNode> reversedGraph, TEnumerator nodeEnumerator, TNode[] selectedLandmarks)
Parameters
Type Name Description
TGraph graph

The graph to select landmarks for

ReversedGraph<TNode> reversedGraph

The reversed graph of the graph.

TEnumerator nodeEnumerator

Enumerator that yields all nodes contained in the graph

TNode[] selectedLandmarks

Array that will be filled with the selected landmarks. The length of this array determines the amount of landmarks that will be selected. Note that the ALT<TNode> implementation currently supports a maximum of 32.

Remarks

This gives better results than SelectRandomLandmarks(TEnumerator, TNode[]), but requires more processing time. It is recommended to enable burst compilation because this can take a long time for large graphs. Consider serializing your landmarks if you use a static world.

SelectFarthestLandmarksUndirected(ref TGraph, TEnumerator, TNode[])

Runs a job on the main thread that selects a set of landmarks that are spaced apart evenly. This method is sufficient for undirected graphs and less computationally expensive than the directed version, since from and to path lengths will be equal.

Declaration
public static void SelectFarthestLandmarksUndirected(ref TGraph graph, TEnumerator nodeEnumerator, TNode[] selectedLandmarks)
Parameters
Type Name Description
TGraph graph

The graph to select landmarks for

TEnumerator nodeEnumerator

Enumerator that yields all nodes contained in the graph

TNode[] selectedLandmarks
Remarks

This gives better results than SelectRandomLandmarks(TEnumerator, TNode[]), but requires more processing time. It is recommended to enable burst compilation because this can take a long time for large graphs. Consider serializing your landmarks if you use a static world.

SelectRandomLandmarks(TEnumerator, TNode[])

Selects a number of random landmarks from a graph.

Declaration
public static void SelectRandomLandmarks(TEnumerator nodeEnumerator, TNode[] selectedLandmarks)
Parameters
Type Name Description
TEnumerator nodeEnumerator

The node enumerator of the graph. Note that this algorithm does not validate if random nodes picked from this enumerator are reachable at all.

TNode[] selectedLandmarks
Remarks

This method is much faster to compute than the Farthest Landmarks selection, but may not produce landmarks that are placed as optimal.

Extension Methods

FinderExtensions.AddOption<T, TNode, TOption>(T, TOption, TNode, TNode)
FinderExtensions.AddOptions<T, TNode, TOption>(T, IEnumerable<TOption>, TNode, Func<TOption, TNode>)
FinderExtensions.AddRange<T, TNode, TOption>(T, IEnumerable<TOption>, TNode, Func<TOption, TNode>)
FinderExtensions.AddRequest<T, TNode>(T, TNode, TNode)
FinderExtensions.AddRequests<T, TNode>(T, IEnumerable<TNode>)
FinderExtensions.AddStop<T, TNode>(T, TNode)
FinderExtensions.AddStops<T, TNode>(T, IEnumerable<TNode>)
FinderExtensions.SetComparer<T, TOption>(T, IComparer<TOption>)
FinderExtensions.SetEdgeMod<T, TMod>(T, TMod)
FinderExtensions.SetGraph<T, TGraph>(T, TGraph)
FinderExtensions.SetHeuristicProvider<T, TH>(T, TH)
FinderExtensions.SetPathProcessor<T, TProc>(T, TProc)
FinderExtensions.SetReserver<T, TOption>(T, IOptionReserver<TOption>)
FinderExtensions.SetStartAndGoal<T, TNode>(T, TNode, TNode)
FinderExtensions.SetValidator<T, TOption>(T, IOptionValidator<TOption>)
In This Article
Back to top Generated by DocFX