concave shapes.

Hey.
Playing around a bit with box2d and came to the idea of seeing if i can make some sort of physics object creation method similar to crayon physics. Where the user can draw shapes into the world with the mouse.

Problem is that then i need to allow concave shapes (because i cant expect the user to only draw convex shapes)
Image

On the wiki it simply says it is not allowed.

So how would you guys do it?..

Is the only solution to break the drawn shape into smaller ones untill only convex shapes exist?
If so how would such an algorithm look, what are the steps involved?
pseudocode would be great 😉
I can't help you at all with the math, but the concave shapes are easily made in this demo: http://www.sideroller.com/wck/

4th Demo.

Best of luck, and don't trust the wiki 😉
I could be mistaken, but I think Crayon Physics is actually creating edges rather than solids. However, the first version (can't recall if the final version did as well) would recognize primitive shapes (boxes & circles) and then snap the drawing into a perfect primitive. --but I believe the only way it's making concave forms is by simply constructing edges.
Found some useful links...

http://www.box2d.org/forum/viewtopic.php?f=8&t=463
http://people.cs.ubc.ca/~snoeyink/demos ... DDemo.html
http://www.ewjordan.com/earClip/
I just added a demo to WCK that does proper crayon-physics-style polygon / circle drawing. The second-to-last demo will take the input points and decompose them into proper polygons. Also, if the points are found to be "circular", it will create a circle rather than a polygon.

If you're not looking to use that port, the code might be handy as a reference implementation at least.

Original thread: https://box2d.org/forum/viewtopic.php?t=4238