Vertices array in mesh vertices

Is there a specific way that unity adds vertices to the mesh.vertices array? Does it differ from mesh to mesh/program to program/ or is it just random altogether(or based on many variables)? I guess all the tools are there for me to determine that the index is of each vertex in a specific mesh, but if they are added to the array in a specifc order i can cut down uv/normal calculations(this would be very optimal if you can hint to how unity handles importing a meshes vertices).

Im still working out the whole uv/normal calc for each vertex using references here from other answers like: @bunny83 's post about subdividing and @Statement 's post about fetching triangles. I actually got inspired by Lasse 's answer to @Fattie 's question about finding nearby triangles, which is basically exactly what i am doing. I want to set up a tree for an equal planes triangles(unitys built-in plane for now)(quadtree built from Start() ?) , i suppose thats the most relevant part of my question/inquiry other than order of vertices in the mesh.vertices array.

Sorry for the compacted question/answer post, hopefully it will inspire others as it has me. I look forward to your insight on this, ive been pondering this question for days now and just trying to figure out the best method before i type it all out(cuz ill probly get lazy and not continue research if i type it out first, at least 'til it becomes a problem :P).

There’s no order other than what you supply. If you say “mesh.vertices = [Vector3(1, 1, 1), Vector3(2, 2, 2), Vector3(3, 3, 3), Vector3(4, 4, 4)];”, then that’s the order. If you’re asking does Unity rearrange them for any reason, then no, it doesn’t.

You have hit on an incredibly critical point here, jinx.

(1) Unity merely uses 3D models, it does not make or decide on them in any way.

It’s important to note that even very sophisticated programmers often misunderstand this.

For example,

Note that someone was saying: “It is an absolutely true statement that Unity shares vertices where it can. There is no situation where this is not true.” … that statement, is utterly incorrect.

but more importantly - the statement doesn’t even make sense. It would be exactly like saying “Microsoft Word only produces crime novels where possible, it never produces action novels” It simply: makes no sense. You could MAYBE say something like “MAYA shares vertices where it can”. (That claim would be totally incorrect and demonstrate a misunderstanding of 3D models.) But the sentence “UNITY shares vertices where it can” is just utterly meaningless - UNITY is to 3D models as your Laser Printer is to Novels. Your laser printer does not make any decisions on anything such as the plot or characters in your novel :slight_smile:

Moving on to the meat of your question.

(2) There is absolutely no - utterly no, whatoever - “rules” about vertex placement in 3D models.

it is very mportant to understand this, and again, even many sophisticated people do not understand this. People not unreasonably think that 3D models must “understand” surfaces, or that 3D models have verts in some arrangement. Again it is totally untrue.

You can read about this at vast length in the yellow comments on the images here

Finally! the true meat of your question!! As you said I’m basically trying to create a quick reference for touching tris…

The answer is!

(3) Unfortunately - and very surprisingly - the 3D pipeline has absolutely, definitely, NO idea about the location of any triangles.

This was very surprising, incredibly surprising, to me when I first was fooling around w/ the 3D pipeline. But that’s how it is. It all makes perfect sense when you get in to it. But the bottom line is, that is exactly what i was asking in this question, just like you “I’m bascially trying to create a quick reference for touching tris”

So unfortunately the simple answer to your issue (“I’m bascially trying to create a quick reference for touching tris”) is that you just have to, when you start up the app, look through the mesh and on your own, build a list (or whatever you want) with the information about touching tris.

Very simply, loop through each tri, look at each edge, and then loop through for a matching one. (again it is discussed at vast length in that other question!)

Hopefully this long-winded reply is of some value to you or others!! Cheers