Here's one small optimization :
Instead of calling TriangleVertex() which creates a array of ints and copies values into it before returning one of those, perhaps this is faster (and more GC friendly)...
Saves one method call too...
Not sure how much faster it is to pull "(t + 1)*3" out of the inner loop and put it in a var, even. But there are lots of those around I see, do I guess it's not important.
Instead of calling TriangleVertex() which creates a array of ints and copies values into it before returning one of those, perhaps this is faster (and more GC friendly)...
' before Local v=surf.TriangleVertex(t,c) ' after Local v=surf.tris[(t + 1)*3 - (c + 1)]
Saves one method call too...
Not sure how much faster it is to pull "(t + 1)*3" out of the inner loop and put it in a var, even. But there are lots of those around I see, do I guess it's not important.