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

Navmesh cutting for fast recast graph updating. More...

Detailed Description

Navmesh cutting for fast recast graph updating.

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

Usually you want a TileHandlerHelper somewhere in your scene which handles applying navmesh cutting when these components are enabled or disabled.

See Also
http://www.arongranberg.com/2013/08/navmesh-cutting/

Public Types

enum  MeshType { Rectangle, Circle, CustomMesh }
 

Public Member Functions

void Awake ()
 
void ForceUpdate ()
 Forces this navmesh cut to update the navmesh.
 
Bounds GetBounds ()
 
void GetContour (List< List< Pathfinding.ClipperLib.IntPoint >> buffer)
 
Vector3 IntPointToV3 (Pathfinding.ClipperLib.IntPoint p)
 
void NotifyUpdated ()
 
void OnDestroy ()
 
void OnDrawGizmos ()
 
void OnDrawGizmosSelected ()
 
void OnEnable ()
 
bool RequiresUpdate ()
 Returns true if this object has moved so much that it requires an update.
 
virtual void UsedForCut ()
 
Pathfinding.ClipperLib.IntPoint V3ToIntPoint (Vector3 p)
 

Static Public Member Functions

static List< NavmeshCutGetAll ()
 Returns a list with all NavmeshCut components in the scene.
 
static List< NavmeshCutGetAllInRange (Bounds b)
 Get all active instances which intersect the bounds.
 

Public Attributes

Vector3 center
 
float circleRadius = 1
 Radius of the circle.
 
int circleResolution = 6
 Number of vertices on the circle.
 
bool cutsAddedGeom = true
 Cuts geometry added by a NavmeshAdd component.
 
float height = 1
 
bool isDual = false
 Only makes a split in the navmesh, but does not remove the geometry to make a hole.
 
Mesh mesh
 Custom mesh to use.
 
float meshScale = 1
 Scale of the custom mesh, if used.
 
Vector2 rectangleSize = new Vector2(1,1)
 Size of the rectangle.
 
MeshType type
 
float updateDistance = 0.4f
 Distance between positions to require an update of the navmesh.
 
float updateRotationDistance = 10
 How many degrees rotation that is required for an update to the navmesh.
 
bool useRotation = false
 Includes rotation in calculations.
 

Static Public Attributes

static readonly Color GizmoColor = new Color(37.0f/255,184.0f/255,239.0f/255)
 

Protected Attributes

Transform tr
 cached transform component
 

Properties

Bounds LastBounds [get]
 

Events

static System.Action< NavmeshCutOnDestroyCallback
 Called every time a NavmeshCut component is destroyed.
 

Private Member Functions

void CalculateMeshContour ()
 

Static Private Member Functions

static void AddCut (NavmeshCut obj)
 
static bool Intersects (Bounds b1, Bounds b2)
 True if b1 and b2 intersects.
 
static void RemoveCut (NavmeshCut obj)
 

Private Attributes

Bounds bounds
 
Vector3[][] contours
 
Bounds lastBounds
 
Mesh lastMesh
 
Vector3 lastPosition
 
Quaternion lastRotation
 
bool wasEnabled
 

Static Private Attributes

static List< NavmeshCutallCuts = new List<NavmeshCut>()
 
static readonly Dictionary
< Pathfinding.Int2, int > 
edges = new Dictionary<Pathfinding.Int2, int>()
 Cached variable, do avoid allocations.
 
static readonly Dictionary
< int, int > 
pointers = new Dictionary<int, int>()
 Cached variable, do avoid allocations.
 

Member Enumeration Documentation

enum MeshType
Enumerator:
Rectangle 
Circle 
CustomMesh 

Member Function Documentation

static void AddCut ( NavmeshCut  obj)
staticprivate
void Awake ( )
void CalculateMeshContour ( )
private
void ForceUpdate ( )

Forces this navmesh cut to update the navmesh.

Note
Dynamic updating requires a Tile Handler Helper somewhere in the scene. This update is not instant, it is done the next time the TileHandlerHelper checks this instance for if it needs updating.
See Also
TileHandlerHelper.ForceUpdate()
static List<NavmeshCut> GetAll ( )
static

Returns a list with all NavmeshCut components in the scene.

Warning
Do not modify this array
static List<NavmeshCut> GetAllInRange ( Bounds  b)
static

Get all active instances which intersect the bounds.

Bounds GetBounds ( )
void GetContour ( List< List< Pathfinding.ClipperLib.IntPoint >>  buffer)
static bool Intersects ( Bounds  b1,
Bounds  b2 
)
staticprivate

True if b1 and b2 intersects.

Note
Faster than Unity's built in version. See http://forum.unity3d.com/threads/204243-Slow-Unity-Math-Please-Unity-Tech-keep-core-math-fast?p=1404070#post1404070
Vector3 IntPointToV3 ( Pathfinding.ClipperLib.IntPoint  p)
void NotifyUpdated ( )
void OnDestroy ( )
void OnDrawGizmos ( )
void OnDrawGizmosSelected ( )
void OnEnable ( )
static void RemoveCut ( NavmeshCut  obj)
staticprivate
bool RequiresUpdate ( )

Returns true if this object has moved so much that it requires an update.

When an update to the navmesh has been done, call NotifyUpdated to be able to get relavant output from this method again.

virtual void UsedForCut ( )
virtual
Pathfinding.ClipperLib.IntPoint V3ToIntPoint ( Vector3  p)

Member Data Documentation

List<NavmeshCut> allCuts = new List<NavmeshCut>()
staticprivate
Bounds bounds
private
Vector3 center
float circleRadius = 1

Radius of the circle.

int circleResolution = 6

Number of vertices on the circle.

Vector3 [][] contours
private
bool cutsAddedGeom = true

Cuts geometry added by a NavmeshAdd component.

You rarely need to change this

readonly Dictionary<Pathfinding.Int2,int> edges = new Dictionary<Pathfinding.Int2, int>()
staticprivate

Cached variable, do avoid allocations.

readonly Color GizmoColor = new Color(37.0f/255,184.0f/255,239.0f/255)
static
float height = 1
bool isDual = false

Only makes a split in the navmesh, but does not remove the geometry to make a hole.

This is slower than a normal cut

Bounds lastBounds
private
Mesh lastMesh
private
Vector3 lastPosition
private
Quaternion lastRotation
private
Mesh mesh

Custom mesh to use.

The contour(s) of the mesh will be extracted. If you get the "max perturbations" error when cutting with this, check the normals on the mesh. They should all point in the same direction. Try flipping them if that does not help.

float meshScale = 1

Scale of the custom mesh, if used.

readonly Dictionary<int,int> pointers = new Dictionary<int, int>()
staticprivate

Cached variable, do avoid allocations.

Vector2 rectangleSize = new Vector2(1,1)

Size of the rectangle.

Transform tr
protected

cached transform component

MeshType type
float updateDistance = 0.4f

Distance between positions to require an update of the navmesh.

A smaller distance gives better accuracy, but requires more updates when moving the object over time, so it is often slower.

Note
Dynamic updating requires a TileHandlerHelper somewhere in the scene.
float updateRotationDistance = 10

How many degrees rotation that is required for an update to the navmesh.

Should be between 0 and 180.

Note
Dynamic updating requires a Tile Handler Helper somewhere in the scene.
bool useRotation = false

Includes rotation in calculations.

This is slower since a lot more matrix multiplications are needed but gives more flexibility.

bool wasEnabled
private

Property Documentation

Bounds LastBounds
get

Event Documentation

System.Action<NavmeshCut> OnDestroyCallback
static

Called every time a NavmeshCut component is destroyed.


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