Sunday, May 06, 2007

Splitting Polygons

Recently, I've been doing some work with BSP trees. One of the problems you run in to is that you need a way to split polygons when they straddle a partitioning plane. I derived some code to do this, before finding this wonderful FAQ that also provides sample code. My code's in Python, whereas the BSP FAQ's code is in C++. The algorithms are basically the same, except I've combined polygon classification with splitting, and I chose to do some more precalculation outside the inner loop. Also, it's in Python so it's slow, but my first priority was correctness. It should be very easy to translate to C/C++.

My code's here. Use it if you want, subject to the MIT (X11) License.

Labels: , ,

0 Comments:

Post a Comment

<< Home