A* Pathfinding Project  4.2.8
The A* Pathfinding Project for Unity 3D
NavmeshAdd Class Reference

Adds new geometry to a recast graph. More...

Detailed Description

Adds new geometry to a recast graph.

This component will add new geometry to a recast graph similar to how a NavmeshCut component removes it.

There are quite a few limitations to this component though. This navmesh geometry will not be connected to the rest of the navmesh in the same tile unless very exactly positioned so that the triangles line up exactly. It will be connected to neighbouring tiles if positioned so that it lines up with the tile border.

This component has a few very specific use-cases. For example if you have a tiled recast graph this component could be used to add bridges in that world. You would create a NavmeshCut object cutting out a hole for the bridge. then add a NavmeshAdd object which fills that space. Make sure NavmeshCut.CutsAddedGeom is disabled on the NavmeshCut, otherwise it will cut away the NavmeshAdd object. Then you can add links between the added geometry and the rest of the world, preferably using NodeLink3.

Public Types

enum  MeshType { Rectangle, CustomMesh }
 

Public Member Functions

override void ForceUpdate ()
 Forces this navmesh add to update the navmesh. More...
 
void GetMesh (ref Int3[] vbuffer, out int[] tbuffer, Pathfinding.Util.GraphTransform inverseTransform=null)
 Copy the mesh to the vertex and triangle buffers after the vertices have been transformed using the inverse of the inverseTransform parameter. More...
 
void RebuildMesh ()
 
override bool RequiresUpdate ()
 Returns true if this object has moved so much that it requires an update. More...
 

Public Attributes

Vector3 center
 
Mesh mesh
 Custom mesh to use. More...
 
float meshScale = 1
 
Vector2 rectangleSize = new Vector2(1, 1)
 Size of the rectangle. More...
 
MeshType type
 
float updateDistance = 0.4f
 Distance between positions to require an update of the navmesh. More...
 
float updateRotationDistance = 10
 How many degrees rotation that is required for an update to the navmesh. More...
 
bool useRotationAndScale
 Includes rotation and scale in calculations. More...
 

Static Public Attributes

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

Protected Member Functions

override void Awake ()
 
- Protected Member Functions inherited from NavmeshClipper
virtual void OnDisable ()
 
virtual void OnEnable ()
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
 
virtual void Reset ()
 Handle serialization backwards compatibility. More...
 

Protected Attributes

Transform tr
 cached transform component More...
 

Package Functions

override Rect GetBounds (Pathfinding.Util.GraphTransform inverseTransform)
 Bounds in XZ space after transforming using the *inverse* transform of the inverseTransform parameter. More...
 
override void NotifyUpdated ()
 Internal method to notify the NavmeshAdd that it has just been used to update the navmesh. More...
 

Properties

Vector3 Center [get]
 
- Properties inherited from NavmeshClipper
static List< NavmeshClipperallEnabled [get]
 All navmesh clipper components in the scene. More...
 

Private Attributes

Vector3 lastPosition
 
Quaternion lastRotation
 
int [] tris
 Cached triangles. More...
 
Vector3 [] verts
 Cached vertices. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from NavmeshClipper
static void AddEnableCallback (System.Action< NavmeshClipper > onEnable, System.Action< NavmeshClipper > onDisable)
 
static void RemoveEnableCallback (System.Action< NavmeshClipper > onEnable, System.Action< NavmeshClipper > onDisable)
 

Member Enumeration Documentation

◆ MeshType

enum MeshType
strong
Enumerator
Rectangle 
CustomMesh 

Member Function Documentation

◆ Awake()

override void Awake ( )
protectedvirtual

Reimplemented from VersionedMonoBehaviour.

◆ ForceUpdate()

override void ForceUpdate ( )
virtual

Forces this navmesh add to update the navmesh.

This update is not instant, it is done the next time it is checked if it needs updating.

See also
Pathfinding.NavmeshUpdates.updateInterval
Pathfinding.NavmeshUpdates.ForceUpdate()

Implements NavmeshClipper.

◆ GetBounds()

override Rect GetBounds ( Pathfinding.Util.GraphTransform  inverseTransform)
packagevirtual

Bounds in XZ space after transforming using the *inverse* transform of the inverseTransform parameter.

The transformation will typically transform the vertices to graph space and this is used to figure out which tiles the add intersects.

Implements NavmeshClipper.

◆ GetMesh()

void GetMesh ( ref Int3 []  vbuffer,
out int []  tbuffer,
Pathfinding.Util.GraphTransform  inverseTransform = null 
)

Copy the mesh to the vertex and triangle buffers after the vertices have been transformed using the inverse of the inverseTransform parameter.

Parameters
vbufferAssumed to be either null or an array which has a length of zero or a power of two. If this mesh has more vertices than can fit in the buffer then the buffer will be pooled using Pathfinding.Util.ArrayPool.Release and a new sufficiently large buffer will be taken from the pool.
tbufferThis will be set to the internal triangle buffer. You must not modify this array.
inverseTransformAll vertices will be transformed using the Pathfinding.GraphTransform.InverseTransform method. This is typically used to transform from world space to graph space.

◆ NotifyUpdated()

override void NotifyUpdated ( )
packagevirtual

Internal method to notify the NavmeshAdd that it has just been used to update the navmesh.

Implements NavmeshClipper.

◆ RebuildMesh()

void RebuildMesh ( )

◆ RequiresUpdate()

override bool RequiresUpdate ( )
virtual

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.

Implements NavmeshClipper.

Member Data Documentation

◆ center

Vector3 center

◆ GizmoColor

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

◆ lastPosition

Vector3 lastPosition
private

◆ lastRotation

Quaternion lastRotation
private

◆ mesh

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.

◆ meshScale

float meshScale = 1

◆ rectangleSize

Vector2 rectangleSize = new Vector2(1, 1)

Size of the rectangle.

◆ tr

Transform tr
protected

cached transform component

◆ tris

int [] tris
private

Cached triangles.

◆ type

MeshType type

◆ updateDistance

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.

◆ updateRotationDistance

float updateRotationDistance = 10

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

Should be between 0 and 180.

◆ useRotationAndScale

bool useRotationAndScale

Includes rotation and scale in calculations.

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

◆ verts

Vector3 [] verts
private

Cached vertices.

Property Documentation

◆ Center

Vector3 Center
get

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