Is there an easy way to find connected vertices in Mesh.vertices?

As of now, Mesh.vertices seems to return 3 vertices for each triangle. However, uin the case of a quad I expected it to be just four, like this:

quad

But on point 0 and 2 in the image, there are two vertices, each with their own normal. I expected these to be connected.

QUESTION: How do I find these “connected” vertices from Mesh.vertices? So in my example, how do I know which two vertices are at point 2.

I of course, can iterate and make groups of vertices which share the exact same position, but I thought maybe Unity had a simpler solution for this.

Thanks in advance :slight_smile:

Usually if a vertex can be shared most modelling tools will share it. So in case of a simple quad you should have 4 vertices and 6 triangle indices (2 * 3 == 2 triangles). Two of the vertices will be shared. However in most cases when it comes to more complex models vertices need to be split because they aren’t equal in each detail.

A vertex is made up by:

  • the position
  • the vertex normal vector
  • texture coodinates (UV)
  • vertex color
  • vertex tangent

If any of those things have to be different for an adjacent triangle, the vertices can’t be shared since they are different. For example a cube has 24 vertices instead of 8 because each “face” / quad will need different UVs and much more important a unique normal. At each corner of the cube you will have 3 vertices at the same position but with 3 different normals so they can’t be shared since they are not the same.

If you just want to find vertices which shared the same position you have to iterate through the vertices array, there’s no way around that since the vertices are not connected in any way.

You want the triangles for the mesh: