Class NavMeshWelder
Utility to weld close vertices in a mesh together.
Namespace: AnyPath.Graphs.NavMesh
Assembly: AnyPath.dll
Syntax
public class NavMeshWelder
Constructors
NavMeshWelder()
Declaration
public NavMeshWelder()
Methods
ScheduleWeld(NativeArray<Vector3>, NativeArray<int>, NativeList<Vector3>, float, JobHandle)
Finds vertices that are close together in a mesh and welds them together. Depending on your mesh this may or may not be neccessary for correct pathfinding, as neighbouring triangles need to share the same vertices.
Declaration
public static JobHandle ScheduleWeld(NativeArray<Vector3> inVertices, NativeArray<int> inOutIndices, NativeList<Vector3> outVertices, float weldThreshold = 0.001, JobHandle dependsOn = default)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArray<Vector3> | inVertices | Original vertices of the mesh |
| NativeArray<int> | inOutIndices | The triangle indices of the mesh. This array is modified in place and will contain the new indices afterwards. |
| NativeList<Vector3> | outVertices | The new unique vertices of the welded mesh, use in conjunction with inOutIndices. This list is not cleared beforehand |
| float | weldThreshold | Distance below which two vertices will be welded together |
| JobHandle | dependsOn | Optional job dependency for the scheduled job |
Returns
| Type | Description |
|---|---|
| JobHandle |
Remarks
This method schedules a burst compiled job doing the work and can be run on another thread.
ScheduleWeld(NativeList<Vector3>, NativeArray<int>, float, JobHandle)
Finds vertices that are close together in a mesh and welds them together. Depending on your mesh this may or may not be neccessary for correct pathfinding, as neighbouring triangles need to share the same vertices.
Declaration
public static JobHandle ScheduleWeld(NativeList<Vector3> inOutVertices, NativeArray<int> inOutIndices, float weldThreshold = 0.001, JobHandle dependsOn = default)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeList<Vector3> | inOutVertices | The vertices to weld together. This list contains the modified vertices afterwards. |
| NativeArray<int> | inOutIndices | The triangle indices of the mesh. This array is modified in place and will contain the new indices afterwards. |
| float | weldThreshold | Distance below which two vertices will be welded together |
| JobHandle | dependsOn | Optional job dependency for the scheduled job |
Returns
| Type | Description |
|---|---|
| JobHandle |
Remarks
This method schedules a burst compiled job doing the work and can be run on another thread.
Weld(List<Vector3>, List<int>, List<Vector3>, float)
Finds vertices that are close together in a mesh and welds them together. Depending on your mesh this may or may not be neccessary for correct pathfinding, as neighbouring triangles need to share the same vertices.
Declaration
public static void Weld(List<Vector3> inOutVertices, List<int> inOutIndices, List<Vector3> outVertices, float weldThreshold)
Parameters
| Type | Name | Description |
|---|---|---|
| List<Vector3> | inOutVertices | The vertices to weld together. This list contains the modified vertices afterwards. |
| List<int> | inOutIndices | The triangle indices to weld together. This list contains the modified triangles afterwards. |
| List<Vector3> | outVertices | List to output the new vertices too, this list should be manually cleared beforehand |
| float | weldThreshold | Distance below which two vertices will be welded together |
Remarks
For best performance, use the native overloads as they can utilize Unity's burst compiler for significant speed gains
Weld(List<Vector3>, List<int>, float)
Finds vertices that are close together in a mesh and welds them together. Depending on your mesh this may or may not be neccessary for correct pathfinding, as neighbouring triangles need to share the same vertices.
Declaration
public static void Weld(List<Vector3> inOutVertices, List<int> inOutIndices, float weldThreshold)
Parameters
| Type | Name | Description |
|---|---|---|
| List<Vector3> | inOutVertices | The vertices to weld together. This list contains the modified vertices afterwards. |
| List<int> | inOutIndices | The triangle indices to weld together. This list contains the modified triangles afterwards. |
| float | weldThreshold | Distance below which two vertices will be welded together |
Remarks
For best performance, use the native overloads as they can utilize Unity's burst compiler for significant speed gains
Weld(NativeArray<Vector3>, NativeArray<int>, NativeList<Vector3>, NativeHashMap<int3, int>, NativeHashMap<int, int>, float)
Finds vertices that are close together in a mesh and welds them together. Depending on your mesh this may or may not be neccessary for correct pathfinding, as neighbouring triangles need to share the same vertices.
Declaration
public static void Weld(NativeArray<Vector3> inVertices, NativeArray<int> inOutIndices, NativeList<Vector3> outVertices, NativeHashMap<int3, int> buckets, NativeHashMap<int, int> shiftedIndices, float weldThreshold = 0.001)
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArray<Vector3> | inVertices | Original vertices of the mesh |
| NativeArray<int> | inOutIndices | The triangle indices of the mesh. This array is modified in place and will contain the new indices afterwards |
| NativeList<Vector3> | outVertices | The new unique vertices of the welded mesh, this list should be cleared beforehand |
| NativeHashMap<int3, int> | buckets | A temporary container used by the algorithm, this list should be cleared beforehand |
| NativeHashMap<int, int> | shiftedIndices | A temporary container used by the algorithm |
| float | weldThreshold | Distance below which two vertices will be welded together |
Remarks
This method can be used inside a burst compiled job