Large Mesh Files

I decided to re-write the mesh load and save routines used by the engine. They were previously using a recursive algorithm, which quickly caused the stack to fill up on larger models with deep hierarchies. Running into a stack overflow situation is simply not acceptable.

I needed to write the objects to the mesh file in depth-first order, similar to the original recursive implementation. Now I see why people like recursive functions, it was very difficult to refactor this into an iterative while loop! I basically had to implement my own stack, that allocates from the heap instead of the limited call stack. Also, keeping track of the nodes that have been visited while unwinding the stack is key.

About Eric DeBrosse

Lead developer of the Orion Engine.
This entry was posted in Engine Development, Game Development and tagged , . Bookmark the permalink.