Struct PathTracer
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.
Inner Types
Public Methods
Appends the given nodes to the start or to the end of the path, one by one.
Checks that invariants are satisfied.
Clears the current path.
Returns a deep clone of this object.
Converts corner indices to world space positions.
Disposes of all unmanaged memory allocated by this path tracer.
Renders the funnel for debugging purposes.
Estimates the remaining distance to the end of the current path part.
Calculate the indices of the next corners in the path.
Calculate the next corners in the path.
Indicates if the given path part is a regular path part or an off-mesh link.
Use a heuristic to determine when an agent has passed a portal and we need to pop it.
Searches from currentNode until it finds a node that contains the given point.
Create a new empty path tracer.
Remove the first count parts of the path.
Replaces the current path with a single node.
Replaces the current path with the given path.
Removes nodes [startIndex, startIndex+toRemove) and then inserts the given nodes at startIndex.
Update the end point of the path, clamping it to the graph, and repairing the path if necessary.
Update the start point of the path, clamping it to the graph, and repairing the path if necessary.
Public Static Methods
Burstified function which checks if a point is inside a triangle-node and if so, projects that point onto the node's surface.
Calculates a lower bound on the remaining distance to the end of the path part.
Removes diagonal connections in a grid path and replaces them with two axis-aligned connections.
Calculates the squared distance from a point to the closest point on the node.
Public Variables
The minimum number of corners to request from GetNextCornerIndices to ensure the path can be simplified well.
End point of the path.
End point of the current path part.
If true, the first part contains destroyed nodes.
True if there is a path to follow.
True if the path is stale and should be recalculated as quickly as possible.
Number of parts in the path.
The type of graph that the current path part is on.
Indicates if portals are definitely not inner corners, or if they may be.
Current start node of the path.
Start point of the path.
Incremented whenever the path is changed.
Public Static Variables
Public Enums
Type of graph that the current path part is on.