I wanted to learn more about box2d and how to decompose complex polygons into a set of convex polygons. I took Mark Bayazit's polygon decomposition algorithm (
http://mnbayazit.com/406/bayazit) and converted it to lua. The code is available at:
https://bitbucket.org/ndoss/gideros_playground/src/428545af7bbf/polydecompOR
https://github.com/ndoss/gideros_playground/tree/master/polydecompThere are some limitations to the example code ...
* if you draw a shape where lines cross, the algorithm will likely not work well
* the example will occasionally crash -- it's got bugs
* the purpose of the code was to play around and learn so it's not very pretty ... I was going to clean things up but since I've got other irons in the fire, I decided I'd go ahead and release it as is
Here's a video of this code ... near the end it has examples that cause the code to do the wrong thing and also to crash.
Comments
Thanks for sharing
evs