After three tries I finally have a base architecture for my triangle grid that works well and is very flexible. Once I finally limited the class to the core functionality of spliting and collapsing triangles everything fell into place. My class is a lot cleaner and simpler, I've added only the minimal code required to keep the mesh coesive. All splitting and rendering logic are done outside of the class. This allowed me to add a a bunch of debug rendering and even some basic splitting code which helped me track down some bugs.

I've been thinking how I can write unit tests for it but the key thing stopping me is being able to come up with complex enough tests and proper test data to compare it to. Most of the bugs I've found have to do with collapsing and rebuilding multiple neighbouring triangles at the same time. Trying to iterate through making sure that all the edges and children are resolving properly sounds like a plan.

Well anyway, here's the exciting bit. Some screenshots of subdivision in action. The first is the basic structure, two head triangles connected to each other. The second show where two rays shot into the mesh cause it to tesselate. It's not amazing at the moment but it's a very important first step. Next step is getting an algorithm together to auto tesselate the mesh based on view position.