I've been looking at the source code for the SurfaceTool, and it seems quite straightforward and to be much like I was expecting it to be.
But then I did more tests, and I noticed a discrepancy between the indices that I feed it with and the indices it gives me back with SurfaceTool.commit_to_arrays()
This is what I feed it with (with the fixed ordering of that face, so there's a total of 24 verts in the mesh):
vertices: [a,b,c,d,e,f,g,h]
indices: [1, 0, 3, 1, 3, 2, 4, 5, 6, 7, 4, 6, 0, 4, 7, 0, 7, 3, 5, 1, 2, 5, 2, 6, 0, 1, 5, 0, 5, 4, 7, 6, 2, 7, 2, 3]
And this is what it gives me back (I converted the Vector3s to letters):
vertices: [b, a, d, c, e, f, g, h, a, e, h, d, f, b, c, g, a, b, f, e, h, g, c, d]
indices[0, 1, 2, 0, 2, 3, 4, 5, 6, 7, 4, 6, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23]
Note that 0=a
in my indices, but in the SurfaceTool 0=b
. Looking at the source code I cannot tell where it does these rearrangements that make it not reuse all the vertices and come up with new indices.
Now I'm even more confused...