- Home /
Combine mesh and merge the neighboring vertices
is there a quick way to make this operation ?
for example when you want to change the different elements and collect the mesh again very often.
Mesh.Combine or other tools - can do it, but they do not allow to merge vertices that are located near...
maybe i need to use SortedDictonary and IComparer(Vertex) - but then takes a long time to build triangles.
please help.
What do you mean by merging vertices? To use the same vertex index?
I'm looking for something similar. Performance is a $$anonymous$$or issue in my case. I'd like a way to combine all vertices in a mesh that are duplicated because unity is splitting geometry along the hard edges. So effectively a way to smooth the geometry at runtime by merging vertices.
Answer by Parthon · Mar 03, 2011 at 04:21 PM
This is very tricky to do properly.
First you would have to find vertexes that are on top of each other. This is at least O(n log n) complexity, increasing in cost as the number of vertexes rises. Then for each match you would delete one vertex, then find all the triangles that reference the second vertex and change that reference to the first vertex.
Of course, none of this would preserve the texture or colour values for the vertex, so the mesh couldn't reliably have textures or colours in it.