Each NURBS curve and surface maintains lists of vectors for control point and knot points. Using this data there are at least three methods of generating buffers of vertex data. I call them "High", "Medium", and "Low". This refers to the theoretical performance of each path. The high path makes use of very recent GPU enhancements. The medium path can be used on GPUs that may be a few years old. The low path is purely CPU bound. There are also one or two specialty routines optimized for certain conditions (think surfaces with only four control points and such).
Each of these paths can now place their generated vertex output into either server side (on GPU memory) or client side (on CPU memory) buffers depending on which is requested. This is done as a "service", in that vertex buffers can be generated for anything, not just rendering. For example, the current curve-curve intersection algorithm generates a buffer of vertex data for each curve and then uses this data to test for intersection, all on the CPU.
In order to get LOD scaling I needed to re-implement the way that these buffers were being generated and maintained. Previously each curve or surface could only manage generating one buffer which then had to be reused for both rendering and intersection and whatever else. Now buffer management is up to whatever asked for the buffer to be generated and memory capacity is the only limit.
I was already passing in the current camera zoom factor into all rendering methods but was not making use of it. Now the zoom factor is used to determine an optimal level-of-detail. If this LOD is close to the LOD of the render buffer nothing happens. If the ratio of optimal-LOD to current-LOD gets too far off then a new render buffer is generated. Overall a pretty good approach I think.
At some point I want to implement a vertex buffer caching scheme. Right now if the rendering routine generates a buffer and then an intersection routine also generates a buffer with the same LOD then two identical buffers get generated. It would be great to better coordinate between them somehow
When it comes to intersection routines my previous estimates of expected code completion were way way off. I pretty much ended up scrapping all of the prior code and started over. There was good reason for this but it required a lot more work. I now have 6 of the 15 routines nearly done. The remaining 9 are all of the ones for NURBS surfaces and trimmed NURBS surfaces. I have an approach in mind for these, it will just take time.
While doing all this work I noticed how incredibly crappy my implementation of trimmed NURBS surfaces was. It worked, just not all that well. I have decided to rewrite most of it. Right now it is mostly trashed. This also led me to look at the code for Pad and Shaft (the two 3D features I had implemented). They were pretty weak also, mostly just proof-of-concept code. I have completely gutted them and it will take a couple of weeks to get them back in shape. As a result the code I will check in this weekend will fix all of the stuff from above, but will kill off any 3D stuff for now. It all compiles but will SEGFAULT quickly upon use. Progress!?!?