/// <summary> /// Condense co-incident vertex positions per-face. vertices must already be marked as shared in the sharedIndexes /// array to be considered. This method is really only useful after merging faces. /// </summary> /// <param name="mesh"></param> /// <param name="faces"></param> internal static void CollapseCoincidentVertices(ProBuilderMesh mesh, IEnumerable <Face> faces) { Dictionary <int, int> lookup = mesh.sharedVertexLookup; Dictionary <int, int> matches = new Dictionary <int, int>(); foreach (Face face in faces) { matches.Clear(); for (int i = 0; i < face.indexesInternal.Length; i++) { int common = lookup[face.indexesInternal[i]]; if (matches.ContainsKey(common)) { face.indexesInternal[i] = matches[common]; } else { matches.Add(common, face.indexesInternal[i]); } } face.InvalidateCache(); } MeshValidation.RemoveUnusedVertices(mesh); }
public static int[] RemoveUnusedVertices(this ProBuilderMesh mesh) { List <int> removed = new List <int>(); MeshValidation.RemoveUnusedVertices(mesh, removed); return(removed.ToArray()); }