
http://en.wikipedia.org/wiki/Recursion_ ... r_science)
code is quite heavily commented. Basic idea is:
-Every time a Mesh is loaded, it automatically gets refreshed, meaning we can load the mesh inside the producer to compute it recorsively.
-Like we do in recursive functions, we calculate the two (or more) sub-problems, then we merge them (by adding the MeshBase and elaborating the whole).
-We use the TreeFlag array as a stack for knowing how much is the dept of the tree we are in. This is a quick and easy to understand solution. I could eliminate everything and only use the P variable but the stack will be handly later on. I use the P as a pointer for the stack current position.
-It's also quite fast for my sake: 4 seconds to elaborate a 9-levels tree (6k triangles)