• 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>

Interface IEdgeMod<TNode>

Namespace: AnyPath.Native
Assembly: AnyPath.dll
Syntax
public interface IEdgeMod<TNode> where TNode : unmanaged, IEquatable<TNode>
Type Parameters
Name Description
TNode

Methods

ModifyCost(in TNode, in TNode, ref float)

Allows for modification of the cost of a path segment, or totally discarding it as a possibility. This is called during the A* algorithm for every segment between locations A* encounters.

Declaration
bool ModifyCost(in TNode from, in TNode to, ref float cost)
Parameters
Type Name Description
TNode from

The source node for this edge

TNode to

The other end of the edge

float cost

Modify this parameter to alter the cost of the segment. Be careful as to not make the cost lower than a value that the heuristic function of the graph would calculate, as this can result in sub optimal paths. For some graph types this may not be immediately noticable but for true graph structures, providing a lower cost than the heuristic may cause the path to contain detours that look strange.

Returns
Type Description
bool

When you return false, the edge is discarded as a possibility. This can be used for instance to simulate a closed door.

Remarks

The default NoProcessing does not touch the cost and returns true. Keeping the original graph as is. The burst compiler is smart enough to detect this and totally discard this method

ModifyEdgeBuffer(in TNode, ref NativeList<Edge<TNode>>)

Allows for modifying the edge buffer after it is filled by the Collect(TNode, ref NativeList<Edge<TNode>>) implementation. This is called every time the algorithm visits a node and right after the default graph implementation has filled it. Leave this method empty if you don't need it. The Burst compiler will strip the code away and this is no impact on performance.

This can be used to create "portals" that aren't part of the default graph. Here's an example for the square grid:

 private SquareGridCell portalFrom;
          private SquareGridCell portalTo;
          public void ModifyEdgeBuffer(in SquareGridCell from, ref NativeList{Edge{SquareGridCell}} edgeBuffer)
          {
             // One portal, but we could also use a hashset to match against many.
             // If we're on the portal position, add an edge/link to the portal destination.
             if (from.Equals(portalFrom))
                 edgeBuffer.Add(new Edge{SquareGridCell}(portalTo, cost: 1));
         }

You can use the generic readymade AdditionalEdges<TNode> modifier for this use case which uses a hashmap internally. If your use case is more specific, there may be more better ways to do it (as the one illustrated above, where there is only one portal).

You can also add other dynamic stuff, or remove edges from the default implementation. While you can remove, it may be more performant to use ModifyCost(in TNode, in TNode, ref float) and return false to discard an edge.

Declaration
void ModifyEdgeBuffer(in TNode from, ref NativeList<Edge<TNode>> edgeBuffer)
Parameters
Type Name Description
TNode from

The node the algorithm is currently at. Similar to Collect(TNode, ref NativeList<Edge<TNode>>).

NativeList<Edge<TNode>> edgeBuffer

Pre filled list containing the edges that originate from from.

Remarks

This can be called multiple times for the same from node. It should act the same every time within a single pathfinding query.

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