A* Pathfinding Project  3.8
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
RVOObstacle Class Referenceabstract

Base class for simple RVO colliders. More...

Detailed Description

Base class for simple RVO colliders.

This is a helper base class for RVO colliders. It provides automatic gizmos and helps with the winding order of the vertices as well as automatically updating the obstacle when moved.

Extend this class to create custom RVO obstacles.

See Also
writing-rvo-colliders
RVOSquareObstacle
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 Types

enum  ObstacleVertexWinding { KeepOut, KeepIn }
 RVO Obstacle Modes. More...
 

Public Member Functions

void OnDisable ()
 Disables the obstacle.
 
void OnDrawGizmos ()
 Draws Gizmos.
 
void OnDrawGizmos (bool selected)
 Draws Gizmos.
 
void OnDrawGizmosSelected ()
 Draws Gizmos.
 
void OnEnable ()
 Enabled the obstacle.
 
void Start ()
 Creates obstacles.
 
void Update ()
 Updates obstacle if required.
 

Public Attributes

RVOLayer layer = RVOLayer.DefaultObstacle
 
ObstacleVertexWinding obstacleMode
 Mode of the obstacle.
 

Protected Member Functions

void AddObstacle (Vector3[] vertices, float height)
 Adds an obstacle with the specified vertices.
 
abstract bool AreGizmosDirty ()
 Called in the editor.
 
abstract void CreateObstacles ()
 Create Obstacles.
 
void FindSimulator ()
 Finds a simulator in the scene.
 
virtual Matrix4x4 GetMatrix ()
 Get's the matrix to use for vertices.
 

Protected Attributes

Pathfinding.RVO.Simulator sim
 Reference to simulator.
 

Properties

abstract bool ExecuteInEditor [get]
 Enable executing in editor to draw gizmos.
 
abstract float Height [get]
 
abstract bool LocalCoordinates [get]
 If enabled, all coordinates are handled as local.
 
abstract bool StaticObstacle [get]
 Static or dynamic.
 

Private Member Functions

void AddObstacleInternal (Vector3[] vertices, float height)
 Adds an obstacle.
 
void WindCorrectly (Vector3[] vertices)
 Winds the vertices correctly.
 

Private Attributes

ObstacleVertexWinding _obstacleMode
 Last obstacle mode.
 
List< ObstacleVertexaddedObstacles
 All obstacles added.
 
bool gizmoDrawing = false
 Enabled if currently in OnDrawGizmos.
 
List< Vector3[]> gizmoVerts
 Vertices for gizmos.
 
Matrix4x4 prevUpdateMatrix
 Last matrix the obstacle was updated with.
 
List< Vector3[]> sourceObstacles
 Original vertices for the obstacles.
 

Member Enumeration Documentation

RVO Obstacle Modes.

Determines winding order of obstacle vertices

Enumerator:
KeepOut 

Keeps agents from entering the obstacle.

KeepIn 

Keeps agents inside the obstacle.

Member Function Documentation

void AddObstacle ( Vector3[]  vertices,
float  height 
)
protected

Adds an obstacle with the specified vertices.

The vertices array might be changed by this function.

void AddObstacleInternal ( Vector3[]  vertices,
float  height 
)
private

Adds an obstacle.

Winding is assumed to be correct and very little error checking is done.

abstract bool AreGizmosDirty ( )
protectedpure virtual

Called in the editor.

This function should return true if any variables which can change the shape or position of the obstacle has changed since the last call to this function. Take a look at the RVOSquareObstacle for an example.

Implemented in RVOSquareObstacle.

abstract void CreateObstacles ( )
protectedpure virtual

Create Obstacles.

Override this and add logic for creating obstacles. You should not use the simulator's function calls directly.

See Also
AddObstacle

Implemented in RVOSquareObstacle.

void FindSimulator ( )
protected

Finds a simulator in the scene.

Saves found simulator in sim.

Exceptions
System.InvalidOperationExceptionWhen no RVOSimulator could be found.
virtual Matrix4x4 GetMatrix ( )
protectedvirtual

Get's the matrix to use for vertices.

Can be overriden for custom matrices.

Returns
transform.localToWorldMatrix if LocalCoordinates is true, otherwise Matrix4x4.identity
void OnDisable ( )

Disables the obstacle.

Do not override this function

void OnDrawGizmos ( )

Draws Gizmos.

void OnDrawGizmos ( bool  selected)

Draws Gizmos.

void OnDrawGizmosSelected ( )

Draws Gizmos.

void OnEnable ( )

Enabled the obstacle.

Do not override this function

void Start ( )

Creates obstacles.

void Update ( )

Updates obstacle if required.

Checks for if the obstacle should be updated (e.g if it has moved)

void WindCorrectly ( Vector3[]  vertices)
private

Winds the vertices correctly.

Winding order is determined from obstacleMode.

Member Data Documentation

ObstacleVertexWinding _obstacleMode
private

Last obstacle mode.

Used to check if the gizmos should be updated

List<ObstacleVertex> addedObstacles
private

All obstacles added.

bool gizmoDrawing = false
private

Enabled if currently in OnDrawGizmos.

List<Vector3[]> gizmoVerts
private

Vertices for gizmos.

RVOLayer layer = RVOLayer.DefaultObstacle
ObstacleVertexWinding obstacleMode

Mode of the obstacle.

Determines winding order of the vertices

Matrix4x4 prevUpdateMatrix
private

Last matrix the obstacle was updated with.

Used to check if the obstacle should be updated

Reference to simulator.

List<Vector3[]> sourceObstacles
private

Original vertices for the obstacles.

Property Documentation

abstract bool ExecuteInEditor
getprotected

Enable executing in editor to draw gizmos.

If enabled, the CreateObstacles function will be executed in the editor as well in order to draw gizmos.

abstract float Height
getprotected
abstract bool LocalCoordinates
getprotected

If enabled, all coordinates are handled as local.

abstract bool StaticObstacle
getprotected

Static or dynamic.

This determines if the obstacle can be updated by e.g moving the transform around in the scene.


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