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

Simple Stupid Funnel Algorithm implementations, used for 'straightening' a path on the NavMesh as much as possible. See http://digestingduck.blogspot.com/2010/03/simple-stupid-funnel-algorithm.html

Inheritance
object
SSFA
Namespace: AnyPath.Graphs.NavMesh
Assembly: AnyPath.dll
Syntax
public static class SSFA
Remarks

It is possible to use this algorithm on other types of paths as well, as long as the segments implement IUnrolledNavMeshGraphPortal

Methods

AppendCornersUnrolled<T>(NativeSlice<T>, NativeList<CornerAndNormal>, float)

Converts a NavMesh path into a set of points that form a path as straight as possible.

Declaration
public static void AppendCornersUnrolled<T>(NativeSlice<T> portals, NativeList<CornerAndNormal> appendTo, float weldThreshold = 0.01) where T : unmanaged, IUnrolledNavMeshGraphPortal
Parameters
Type Name Description
NativeSlice<T> portals

The raw path from the NavMesh.

NativeList<CornerAndNormal> appendTo

List to append the corner points to

float weldThreshold

Weld corners that are below this distance together. This can prevent multiple corners at the same position where 3 or more triangles in the path intersect

Type Parameters
Name Description
T
Remarks

This method works for curved worlds. See NavMeshGraphCorners3D

AppendCorners<TProj>(NativeSlice<TProj>, NativeList<float3>)

Converts a NavMesh path into a set of points that form a path as straight as possible.

Declaration
public static void AppendCorners<TProj>(NativeSlice<TProj> portals, NativeList<float3> appendTo) where TProj : unmanaged, IUnrolledNavMeshGraphPortal
Parameters
Type Name Description
NativeSlice<TProj> portals

The raw path from the NavMesh.

NativeList<float3> appendTo

List to append the corner points to

Type Parameters
Name Description
TProj
Remarks

This method works for 'flat' worlds. See NavMeshGraphCorners

GetSteerTargetPosition<T>(T, float3, ref int)

Returns a target position to steer towards, based on a pre processed path by NavMeshGraphUnroller. This method should be called each update with the most recent position of the agent that traverses the path. The target position is dynamically calculated based on the current position of the agent. This allows for more fluid steering instead of following a fixed set of corner points. To get a steering direction, subtract the current position from the target position and normalize the result.

Declaration
public static float3 GetSteerTargetPosition<T>(this T portals, float3 currentPosition, ref int index) where T : IPathSegments<UnrolledNavMeshGraphPortal>
Parameters
Type Name Description
T portals

The processed path by NavMeshGraphUnroller. In a managed context, you can just pass in the Path<TSeg> object. In ECS/Burst context, use NativeListWrapper<TSeg>.

float3 currentPosition

The current position of the agent traversing the path.

int index

The index in the path. This value is automatically incremented based on the input position. Note that this value is never decreased, so if your agent deviates from the path too much, a new path may need to be calculated.

Returns
Type Description
float3

The ideal point to move towards, preserving the curvature of the mesh.

Type Parameters
Name Description
T

The type of path, see UnrolledNavMeshGraphPortal and NativeListWrapper<TSeg>

Remarks

Be cautious with slow steering as that may cause the agent to move outside of the known path. Small deviations are usually OK, but if your agent ends up moving backwards in the path, the direction value may not be reliable anymore.

This method works with full 3D curved worlds, but as such, the returned position is never further away than the next triangle in the path. Take care as to not move beyond the target position if your agent has a high velocity. If this is the case, move towards the target position and call this method again to get a new target position.

It's recommended to combine this method of navigating with other forms of collision detection in your world.

Exceptions
Type Condition
ArgumentOutOfRangeException

If the index is out of range

Intersect<T>(T, float2, float2)

Takes the 2D line and calculates the intersection with a portal. Returns the original point in 3D space.

Declaration
public static float3 Intersect<T>(this T proj, float2 oldApex, float2 newApex) where T : IUnrolledNavMeshGraphPortal
Parameters
Type Name Description
T proj
float2 oldApex
float2 newApex
Returns
Type Description
float3
Type Parameters
Name Description
T
In This Article
Back to top Generated by DocFX