After reworking a few vector macros and the addition of graphics-specific clipping mechanics I finally found an acceptably compact solution for n-dimensional rect/box/cube/whatever clipping. I wanted to have code that's also useful for more other, more advanced uses and I think I found a good base. The idea is similar to how SDL handles clipping: dst rect and source rect (clip rects and dst position in SDL) undergo some vector operations and out-of-clip checks to have a final dst iteration range and an offset that can be added to the iteration position to get a matching src position. One may call a fool to do this all by hand but it's no easy or totally trivial. Everyone who tried writing a proper and covering voxel cube clipper will know what I mean. I still believe that is the best possible approach if you want to become at what you do.

No comments: