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

Adds a navmesh as RVO obstacles. More...

Detailed Description

Adds a navmesh as RVO obstacles.

Add this to a scene in which has a navmesh or grid based graph, when scanning (or loading from cache) the graph it will be added as RVO obstacles to the RVOSimulator (which must exist in the scene).

Warning
You should only have a single instance of this script in the scene, otherwise it will add duplicate obstacles and thereby increasing the CPU usage.

If you update a graph during runtime the obstacles need to be recalculated which has a performance penalty. This can be quite significant for larger graphs.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

Public Member Functions

override void OnGraphsPostUpdate ()
 Called after graphs have been updated using GraphUpdateObjects.
 
override void OnLatePostScan ()
 Called at the end of the scanning procedure.
 
override void OnPostCacheLoad ()
 Called after cached graphs have been loaded.
 
void RemoveObstacles ()
 Removes all obstacles which have been added by this component.
 
- Public Member Functions inherited from GraphModifier
virtual void OnGraphsPreUpdate ()
 Called before graphs are updated using GraphUpdateObjects.
 
virtual void OnPostScan ()
 Called right after all graphs have been scanned.
 
virtual void OnPreScan ()
 Called right before graphs are going to be scanned.
 

Public Attributes

float wallHeight = 5
 Height of the walls added for each obstacle edge.
 

Private Member Functions

void AddGraphObstacles (Pathfinding.RVO.Simulator sim, GridGraph grid)
 
void AddGraphObstacles (Pathfinding.RVO.Simulator sim, INavmesh ng)
 Adds obstacles for a graph.
 

Static Private Member Functions

static void CompressContour (Dictionary< int, int > outline, HashSet< int > hasInEdge, System.Action< List< int >, bool > results)
 
static void FindAllContours (GridGraph grid, System.Action< Vector3[], bool > callback, GridNodeBase[] nodes=null)
 Finds all contours of a collection of nodes in a grid graph.
 

Private Attributes

Simulator lastSim
 Last simulator used.
 
readonly List< ObstacleVertexobstacles = new List<ObstacleVertex>()
 Obstacles currently added to the simulator.
 

Additional Inherited Members

- Public Types inherited from GraphModifier
enum  EventType {
  PostScan = 1 << 0, PreScan = 1 << 1, LatePostScan = 1 << 2, PreUpdate = 1 << 3,
  PostUpdate = 1 << 4, PostCacheLoad = 1 << 5
}
 GraphModifier event type. More...
 
- Static Public Member Functions inherited from GraphModifier
static void FindAllModifiers ()
 
static void TriggerEvent (GraphModifier.EventType type)
 Triggers an event for all active graph modifiers.
 
- Protected Member Functions inherited from GraphModifier
override void Awake ()
 
virtual void OnDestroy ()
 
virtual void OnDisable ()
 Removes this modifier from list of active modifiers.
 
virtual void OnEnable ()
 Adds this modifier to list of active modifiers.
 
- Static Protected Member Functions inherited from GraphModifier
static List< T > GetModifiersOfType< T > ()
 
- Protected Attributes inherited from GraphModifier
ulong uniqueID
 Unique persistent ID for this component, used for serialization.
 
- Static Protected Attributes inherited from GraphModifier
static Dictionary< ulong,
GraphModifier
usedIDs = new Dictionary<ulong, GraphModifier>()
 Maps persistent IDs to the component that uses it.
 

Member Function Documentation

void AddGraphObstacles ( Pathfinding.RVO.Simulator  sim,
GridGraph  grid 
)
private
void AddGraphObstacles ( Pathfinding.RVO.Simulator  sim,
INavmesh  ng 
)
private

Adds obstacles for a graph.

static void CompressContour ( Dictionary< int, int >  outline,
HashSet< int >  hasInEdge,
System.Action< List< int >, bool >  results 
)
staticprivate
static void FindAllContours ( GridGraph  grid,
System.Action< Vector3[], bool >  callback,
GridNodeBase[]  nodes = null 
)
staticprivate

Finds all contours of a collection of nodes in a grid graph.

In the image below you can see the contour of a graph.

In the image below you can see the contour of just a part of a grid graph (when the nodes parameter is supplied)

Contour of a hexagon graph

Parameters
gridThe grid to find the contours of
callbackThe callback will be called once for every contour that is found, the first parameter is the vertices and the second parameter indicates if that contour is a cycle or if it is just a chain (chains can only occur when you explicitly specify some nodes to search
nodesOnly these nodes will be searched. If this parameter is null then all nodes in the grid graph will be searched.
var grid = AstarPath.data.gridGraph;
// Find all contours in the graph and draw them using debug lines
FindAllContours(grid, (vertices, cycle) => {
int end = cycle ? vertices.Length : vertices.Length - 1;
for (int i = 0; i < end; i++) {
Debug.DrawLine(vertices[i], vertices[(i+1)%vertices.Length], Color.red, 4);
}
});
override void OnGraphsPostUpdate ( )
virtual

Called after graphs have been updated using GraphUpdateObjects.

Eventual flood filling has been done

Reimplemented from GraphModifier.

override void OnLatePostScan ( )
virtual

Called at the end of the scanning procedure.

This is the absolute last thing done by Scan.

Reimplemented from GraphModifier.

override void OnPostCacheLoad ( )
virtual

Called after cached graphs have been loaded.

When using cached startup, this event is analogous to OnLatePostScan and implementing scripts should do roughly the same thing for both events.

Reimplemented from GraphModifier.

void RemoveObstacles ( )

Removes all obstacles which have been added by this component.

Member Data Documentation

Simulator lastSim
private

Last simulator used.

readonly List<ObstacleVertex> obstacles = new List<ObstacleVertex>()
private

Obstacles currently added to the simulator.

float wallHeight = 5

Height of the walls added for each obstacle edge.

If a graph contains overlapping regions (e.g multiple floor in a building) you should set this low enough so that edges on different levels do not interfere, but high enough so that agents cannot move over them by mistake.


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