Struct PathTracer

Public

Helper for following a path.

This struct keeps track of the path from the agent's current position to the end of the path. Whenever the agent moves you should call UpdateStart to update the path. This will automatically update the path if the agent has moved to the next node, or repair the path if the agent has been pushed away into a node which wasn't even on the original path. If the destination changes you should call UpdateEnd to update the path. This also repairs the path and it allows you to instantly get a valid path to the new destination, unless the destination has changed so much that the repair is insufficient. In that case you will have to wait for the next path recalculation. Check isStale to see if the PathTracer recommends that the path be recalculated.

After repairing the path, it will be valid, but it will not necessarily be the shortest possible path. Therefore it is still recommended that you recalculate the path every now and then.

The PathTracer stores the current path as a series of nodes. When the direction to move in is requested (by calling GetNextCorners), a path will be found which passes through all those nodes, using the funnel algorithm to simplify the path. In some cases the path will contain inner vertices which make the path longer than it needs to be. Those will be iteratively removed until the path is as short as possible. For performance only a limited number of iterations are performed per frame, but this is usually fast enough that the simplification appears to be instant.

Public Methods

AppendNode (toStart, node)
Public
AppendPath (toStart, path)

Appends the given nodes to the start or to the end of the path, one by one.

Public
CalculateFunnelPortals (startNodeIndex, endNodeIndex, outLeftPortals, outRightPortals)
Public
CheckInvariants ()

Checks that invariants are satisfied.

Public
Clear ()
Public
ConvertCornerIndicesToPathProjected (cornerIndices, numCorners, lastCorner, buffer, up)
Public
Dispose ()
Public
DrawGizmos (draw, movementPlane)
Public
EstimateRemainingPath (maxCorners, movementPlane)

Estimates the remaining distance to the end of the current path part.

Public
FirstInnerVertex (indices, numCorners, alternativePath, alternativeStartIndex, alternativeEndIndex)
Public
GetLinkInfo (partIndex=0)
Public
GetNextCornerIndices (buffer, maxCorners, allocator, lastCorner)
Public
GetNextCorners (buffer, maxCorners, scratchArray, allocator)

Calculate the next corners in the path.

Public
GetPartType (partIndex=0)
Public
HeuristicallyPopPortals (isStartOfPart, point)

Use a heuristic to determine when an agent has passed a portal and we need to pop it.

Public
PathTracer (allocator)
Public
PopParts (count)
Public
RemoveAllPartsExceptFirst ()
Public
Repair (point, isStart, quality, movementPlane, allowCache=true)
Public
RepairFull (point, isStart, quality, movementPlane)
Public
SetFromSingleNode (node, position, movementPlane)
Public
SetFunnelState (part)
Public
SetPath (parts, nodes, unclampedStartPoint, unclampedEndPoint, movementPlane)
Public
SplicePath (startIndex, toRemove, toInsert)

Removes nodes [startIndex, startIndex+toRemove) and then inserts the given nodes at startIndex.

Public
UpdateEnd (position, quality, movementPlane)
Public
UpdateStart (position, quality, movementPlane)
Public

Public Static Methods

ContainsAndProject (a, b, c, p, height, movementPlane, projected)

Burstified function which checks if a point is inside a triangle-node and if so, projects that point onto the node's surface.

Public Static
ContainsPoint (node, point, plane)
Public Static
ContainsPoint (node, point, plane, height)
Public Static
EstimateRemainingPath (funnelState, part, maxCorners, movementPlane)
Public Static
IsInnerVertex (nodes, part, portalIndex, rightSide, alternativeNodes, startIndex, endIndex)
Public Static
MaybeSetYZero (p, setYToZero)
Public Static
ProjectOnSurface (a, b, c, p, up)
Public Static
ProjectOnSurface (node, point, plane)
Public Static
ProjectOnSurface (node, point, plane)
Public Static
RemainingDistanceLowerBound (nextCorners, endOfPart, movementPlane)
Public Static

Public Variables

endIsUpToDate
Public
endPoint
Public
endPointOfFirstPart
Public
firstPartContainsDestroyedNodes

If true, the first part contains destroyed nodes.

Public
firstPartIndex
Public
funnelState
Public
hasPath
Public
isCreated
Public
isStale

True if the path is stale and should be recalculated.

Public
nodes
Public
partCount

Number of parts in the path.

Public
parts
Public
portalIsNotInnerCorner

Indicates if portals are definitely not inner corners, or if they may be.

Public
startIsUpToDate
Public
startNode

Current start node of the path.

Public
startNodeInternal
Public
startPoint
Public
unclampedEndPoint
Public
unclampedStartPoint
Public
version

Incremented whenever the path is changed.

Public

Public Static Variables

NODES_TO_CHECK_FOR_DESTRUCTION
Public Static

Public Enums

RepairQuality
Public

Private/Protected Members

MarkerClosest
Private Static Readonly
MarkerContains
Private Static Readonly
MarkerGetNearest
Private Static Readonly
scratchList
Private Static