public static void GatherVertices(OctreeNode n, List<Vertex> dest, ref int surface_index)
{
if (n == null)
return;
if (n.size > 1)
{
for (int i = 0; i < 8; i++)
GatherVertices(n.children[i], dest, ref surface_index);
}
else
{
foreach (Vertex v in n.vertices)
{
if (v.surface_index == -1)
{
v.surface_index = surface_index++;
dest.Add(v);
}
}
}
}