Class VertexEditing
Methods for merging and splitting common (or shared) vertices.
Namespace: UnityEngine.ProBuilder.MeshOperations
Syntax
public static class VertexEditing
Methods
MergeVertices(ProBuilderMesh, Int32[], Boolean)
Collapses all passed indexes to a single shared index.
Declaration
public static int MergeVertices(this ProBuilderMesh mesh, int[] indexes, bool collapseToFirst = false)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | Target mesh. |
Int32[] | indexes | The indexes to merge to a single shared vertex. |
Boolean | collapseToFirst | If true, instead of merging all vertices to the average position, the vertices will be collapsed onto the first vertex position. |
Returns
Type | Description |
---|---|
Int32 | The first available local index created as a result of the merge. -1 if action is unsuccessfull. |
Remarks
Retains vertex normals.
SplitVertices(ProBuilderMesh, IEnumerable<Int32>)
Split vertices from their shared indexes so that each vertex moves independently.
Declaration
public static void SplitVertices(this ProBuilderMesh mesh, IEnumerable<int> vertices)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
IEnumerable<Int32> | vertices | A list of vertex indexes to split. |
See Also
SplitVertices(ProBuilderMesh, Edge)
Split the vertices referenced by edge from their shared indexes so that each vertex moves independently.
Declaration
public static void SplitVertices(this ProBuilderMesh mesh, Edge edge)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | The source mesh. |
Edge | edge | The edge to query for vertex indexes. |
Remarks
This is equivalent to calling SplitVertices(mesh, new int[] { edge.x, edge.y });
.
See Also
WeldVertices(ProBuilderMesh, IEnumerable<Int32>, Single)
Similar to Merge vertices, expect that this method only collapses vertices within a specified distance of one another (typically Mathf.Epsilon is used).
Declaration
public static int[] WeldVertices(this ProBuilderMesh mesh, IEnumerable<int> indexes, float neighborRadius)
Parameters
Type | Name | Description |
---|---|---|
ProBuilderMesh | mesh | Target pb_Object. |
IEnumerable<Int32> | indexes | The vertex indexes to be scanned for inclusion. To weld the entire object for example, pass pb.faces.SelectMany(x => x.indexes). |
Single | neighborRadius | The minimum distance from another vertex to be considered within welding distance. |
Returns
Type | Description |
---|---|
Int32[] | The indexes of any new vertices created by a weld. |