My first proper contribution to the wonderful Box2D engine, specifically the Flash port. I’ve added a third shape type to the engine, which dramatically increases the possible shapes you can describe. Hopefully my contribution will also show other people how to add shapes, and some of the deeper aspects of the engine.
It’s easier to describe than see, so try out a demo: Demo
Usage
b2ConcaveArcShape
This shape can represent any polygon with a circle subtracted from it. It works exactly the same as b2PolygonShape
, except the edge from vertex 0 to vertex 1 is a concave arc, with radius given by the radius
property. The diameter should be longer than the distance between the vertices, and the rest of the polygonal shape should be large enough to enclose the resulting curve (this is not checked).
Bugs
There’s still a few outstanding issues, but I’m waiting for someone to complain and/or show reproducible bugs.
The biggest bug is that concave arcs do not collide with each other. I find this code too hard to write (at least, using solid shapes rather than thin arcs, which are simpler), but last time people reassured me they mainly wanted such shapes for static scenery, so this isn’t a huge problem. Masses are not calculated correctly either.
Also, when you pull objects against a static concave arc, and then slide them over one of the two vertices at the ends of the arc, you sometimes see ‘popping’. I think it’s some warm starting issue, but I cannot reproduce it reliably, so if you can, let me know. Also, I haven’t written TestSegment
code, though this is rather trivial compared with the rest.
Update
I’ve ceased maintaining this code, so there are no coming features. The whole thing is a bit of a mess, and never that useful. I do have a semi-updated version for Box2D 2.0, but I’m not going to finish it until I actually have a reason to. At least some good game of it: John Nesky aka shaktool, used my work as inspiration for adding segment edges (line meshes) into Box2D, a much needed feature.