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

Classes

struct  GUOSingle
 Holds a single update that needs to be performed on a graph. More...
 

Public Member Functions

 GraphUpdateProcessor (AstarPath astar)
 
void DisableMultithreading ()
 
void EnableMultithreading ()
 
void FloodFill (GraphNode seed)
 Floodfills starting from the specified node.
 
void FloodFill (GraphNode seed, uint area)
 Floodfills starting from 'seed' using the specified area.
 
void FloodFill ()
 Floodfills all graphs and updates areas for every node.
 
AstarWorkItem GetWorkItem ()
 Work item which can be used to apply all queued updates.
 
void UpdateGraphs (GraphUpdateObject ob)
 Update all graphs using the GraphUpdateObject.
 

Properties

bool IsAnyGraphUpdateInProgress [get]
 Returns if any graph updates are in progress.
 
bool IsAnyGraphUpdateQueued [get]
 Returns if any graph updates are waiting to be applied.
 

Events

System.Action OnGraphsUpdated
 

Private Types

enum  GraphUpdateOrder { GraphUpdate, FloodFill }
 Order type for updating graphs. More...
 

Private Member Functions

bool ProcessGraphUpdates (bool force)
 Updates graphs.
 
void ProcessGraphUpdatesAsync ()
 Graph update thread.
 
void ProcessPostUpdates ()
 
bool ProcessRegularUpdates (bool force)
 
void QueueGraphUpdatesInternal ()
 Schedules graph updates internally.
 
bool StartAsyncUpdatesIfQueued ()
 Signal the graph update thread to start processing graph updates if there are any in the graphUpdateQueueAsync queue.
 

Private Attributes

bool anyGraphUpdateInProgress
 Used for IsAnyGraphUpdateInProgress.
 
readonly AstarPath astar
 Holds graphs that can be updated.
 
readonly
System.Threading.ManualResetEvent 
asyncGraphUpdatesComplete = new System.Threading.ManualResetEvent(true)
 
readonly
System.Threading.AutoResetEvent 
exitAsyncThread = new System.Threading.AutoResetEvent(false)
 
readonly
System.Threading.AutoResetEvent 
graphUpdateAsyncEvent = new System.Threading.AutoResetEvent(false)
 
readonly Queue< GraphUpdateObjectgraphUpdateQueue = new Queue<GraphUpdateObject>()
 Stack containing all waiting graph update queries.
 
readonly Queue< GUOSinglegraphUpdateQueueAsync = new Queue<GUOSingle>()
 Queue of all async graph updates waiting to be executed.
 
readonly Queue< GUOSinglegraphUpdateQueuePost = new Queue<GUOSingle>()
 Queue of all non-async graph update post events waiting to be executed.
 
readonly Queue< GUOSinglegraphUpdateQueueRegular = new Queue<GUOSingle>()
 Queue of all non-async graph updates waiting to be executed.
 
Thread graphUpdateThread
 Reference to the thread which handles async graph updates.
 
uint lastUniqueAreaIndex = 0
 The last area index which was used.
 

Member Enumeration Documentation

enum GraphUpdateOrder
private

Order type for updating graphs.

Enumerator:
GraphUpdate 
FloodFill 

Constructor & Destructor Documentation

Member Function Documentation

void DisableMultithreading ( )
void EnableMultithreading ( )
void FloodFill ( GraphNode  seed)

Floodfills starting from the specified node.

See Also
https://en.wikipedia.org/wiki/Flood_fill
void FloodFill ( GraphNode  seed,
uint  area 
)

Floodfills starting from 'seed' using the specified area.

See Also
https://en.wikipedia.org/wiki/Flood_fill
void FloodFill ( )

Floodfills all graphs and updates areas for every node.

The different colored areas that you see in the scene view when looking at graphs are called just 'areas', this method calculates which nodes are in what areas.

See Also
Pathfinding.Node.area
AstarWorkItem GetWorkItem ( )

Work item which can be used to apply all queued updates.

bool ProcessGraphUpdates ( bool  force)
private

Updates graphs.

Will do some graph updates, possibly signal another thread to do them. Will only process graph updates added by QueueGraphUpdatesInternal

Parameters
forceIf true, all graph updates will be processed before this function returns. The return value will be True.
Returns
True if all graph updates have been done and pathfinding (or other tasks) may resume. False if there are still graph updates being processed or waiting in the queue.
void ProcessGraphUpdatesAsync ( )
private

Graph update thread.

Async graph updates will be executed by this method in another thread.

void ProcessPostUpdates ( )
private
bool ProcessRegularUpdates ( bool  force)
private
void QueueGraphUpdatesInternal ( )
private

Schedules graph updates internally.

bool StartAsyncUpdatesIfQueued ( )
private

Signal the graph update thread to start processing graph updates if there are any in the graphUpdateQueueAsync queue.

Returns
True if the other thread was signaled.
void UpdateGraphs ( GraphUpdateObject  ob)

Update all graphs using the GraphUpdateObject.

This can be used to, e.g make all nodes in an area unwalkable, or set them to a higher penalty. The graphs will be updated as soon as possible (with respect to #batchGraphUpdates)

See Also
FlushGraphUpdates

Member Data Documentation

bool anyGraphUpdateInProgress
private

Used for IsAnyGraphUpdateInProgress.

readonly AstarPath astar
private

Holds graphs that can be updated.

readonly System.Threading.ManualResetEvent asyncGraphUpdatesComplete = new System.Threading.ManualResetEvent(true)
private
readonly System.Threading.AutoResetEvent exitAsyncThread = new System.Threading.AutoResetEvent(false)
private
readonly System.Threading.AutoResetEvent graphUpdateAsyncEvent = new System.Threading.AutoResetEvent(false)
private
readonly Queue<GraphUpdateObject> graphUpdateQueue = new Queue<GraphUpdateObject>()
private

Stack containing all waiting graph update queries.

Add to this stack by using UpdateGraphs

See Also
UpdateGraphs
readonly Queue<GUOSingle> graphUpdateQueueAsync = new Queue<GUOSingle>()
private

Queue of all async graph updates waiting to be executed.

readonly Queue<GUOSingle> graphUpdateQueuePost = new Queue<GUOSingle>()
private

Queue of all non-async graph update post events waiting to be executed.

readonly Queue<GUOSingle> graphUpdateQueueRegular = new Queue<GUOSingle>()
private

Queue of all non-async graph updates waiting to be executed.

Thread graphUpdateThread
private

Reference to the thread which handles async graph updates.

See Also
ProcessGraphUpdatesAsync
uint lastUniqueAreaIndex = 0
private

The last area index which was used.

Used for the FloodFill function to start flood filling with an unused area.

See Also
FloodFill(Node node)

Property Documentation

bool IsAnyGraphUpdateInProgress
get

Returns if any graph updates are in progress.

bool IsAnyGraphUpdateQueued
get

Returns if any graph updates are waiting to be applied.

Event Documentation

System.Action OnGraphsUpdated

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