Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Example w/ box2d and Mark Bayazit's polygon decomposition algorithm — Gideros Forum

Example w/ box2d and Mark Bayazit's polygon decomposition algorithm

ndossndoss Guru
edited March 2012 in Code snippets
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/polydecomp

OR

https://github.com/ndoss/gideros_playground/tree/master/polydecomp

There 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.



+1 -1 (+4 / -0 )Share on Facebook

Comments

Sign In or Register to comment.