A* Pathfinding Project  4.0.11
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
RecastTileUpdateHandler Class Reference

Helper for easier fast updates to recast graphs. More...

Detailed Description

Helper for easier fast updates to recast graphs.

When updating recast graphs, you might just have plonked down a few GraphUpdateScene objects or issued a few GraphUpdateObjects to the system. This works fine if you are only issuing a few but the problem is that they don't have any coordination in between themselves. So if you have 10 GraphUpdateScene objects in one tile, they will all update that tile (10 times in total) instead of just updating it once which is all that is required (meaning it will be 10 times slower than just updating one tile). This script exists to help with updating only the tiles that need updating and only updating them once instead of multiple times.

It is coupled with the RecastTileUpdate component, which works a bit like the GraphUpdateScene component, just with fewer options. You can attach the RecastTileUpdate to any GameObject to have it schedule an update for the tile(s) that contain the GameObject. E.g if you are creating a new building somewhere, you can attach the RecastTileUpdate component to it to make it update the graph when it is instantiated.

If a single tile contains multiple RecastTileUpdate components and many try to update the graph at the same time, only one tile update will be done, which greatly improves performance.

If you have objects that are instantiated at roughly the same time but not exactly the same frame, you can use the maxThrottlingDelay field. It will delay updates up to that number of seconds to allow more updates to be batched together.

Note
You should only have one instance of this script in the scene if you only have a single recast graph. If you have more than one graph you can have more than one instance of this script but you need to manually call the SetGraph method to configure it with the correct graph.
This does not use navmesh cutting. If you only ever add obstacles, but never add any new walkable surfaces then you might want to use navmesh cutting instead. See Navmesh Cutting.

Public Member Functions

void ScheduleUpdate (Bounds bounds)
 Requests an update to all tiles which touch the specified bounds.
 
void SetGraph (RecastGraph graph)
 
void UpdateDirtyTiles ()
 Update all dirty tiles now.
 

Public Attributes

float maxThrottlingDelay = 0.5f
 All tile updates will be performed within (roughly) this number of seconds.
 

Private Member Functions

void OnDisable ()
 
void OnEnable ()
 
void Update ()
 

Private Attributes

bool anyDirtyTiles = false
 True if any elements in dirtyTiles are true.
 
bool[] dirtyTiles
 True for a tile if it needs updating.
 
float earliestDirty = float.NegativeInfinity
 Earliest update request we are handling right now.
 
RecastGraph graph
 Graph that handles the updates.
 

Member Function Documentation

void OnDisable ( )
private
void OnEnable ( )
private
void ScheduleUpdate ( Bounds  bounds)

Requests an update to all tiles which touch the specified bounds.

void SetGraph ( RecastGraph  graph)
void Update ( )
private
void UpdateDirtyTiles ( )

Update all dirty tiles now.

Member Data Documentation

bool anyDirtyTiles = false
private

True if any elements in dirtyTiles are true.

bool [] dirtyTiles
private

True for a tile if it needs updating.

float earliestDirty = float.NegativeInfinity
private

Earliest update request we are handling right now.

RecastGraph graph
private

Graph that handles the updates.

float maxThrottlingDelay = 0.5f

All tile updates will be performed within (roughly) this number of seconds.


The documentation for this class was generated from the following file: