I have taken my Box2D branch down, because Edge Shapes are now merged into the main C++ Box2D branch.

Thanks to kne for the help with fixing bugs.
I have ported my
line segment shapes from Flash to C++, and also updated the features, api, and robustness.

As always, feedback and bug reports are welcome.
Example:
Code:
// A concave square room:
float32 coords[] =
{
-10.0f, -10.0f,
-10.0f, 10.0f,
10.0f, 10.0f,
10.0f, -10.0f
};
b2Vec2 vertices[4];
for (int i = 0; i < 4; i++) {
vertices[i].Set(coords[i*2], coords[i*2 + 1]);
}
b2BodyDef bd;
b2Body* body = m_world->CreateBody(&bd);
b2EdgeChainDef chain;
chain.isALoop = true; // connects the first and last vertices
chain.vertexCount = 4;
chain.vertices = vertices;
body->CreateShape(&chain);
Notes:
- The shapes are called b2EdgeShapes now. I dropped the word "Static" from the name because they're not forced to be static anymore.
- Edges Shapes have a "correct" side and a "wrong" side to collide with. Which is which depends on your coordinate system. If up is positive on the Y axis, floors go from right to left, and ceilings go from left to right. If up is negative, floors go from left to right and ceilings go from right to left. This is consistent with the vertex order of Polygons. If a shape touches the wrong side of an edge, it will be yanked to the correct side, after which it will collide with the correct side normally. However, there's no restriction on whether the edges form convex or concave geometry (which is really the whole point of these edges!).
- The definition object is called b2EdgeChainDef. Chain definitions are used to create adjacent b2EdgeShapes with shared vertices. Unlike b2PolygonDefs, you must allocate the memory for the arrays of vertices in the shape definition object on your own until you're done with the definition, and then you may deallocate the array. Also unlike b2Polygons, you're not limited to just eight vertices at a time. I added the word "chain" to the name of the definition files to emphasize that there is a one-to-many relationship between edge definitions and edge shapes. Technically, you can create one edge at a time by using chains with only two vertices, but that's less efficient and slightly less robust at continuous physics.
- You can attach the edge shapes to any body now, not just the ground body. b2Body::CreateShape() will create one b2EdgeShape for every pair of adjacent vertices in the definition file. It will return a reference to the first of these shapes. Each edge shape contains a reference to the next and previous edge shapes, so you can iterate over the edges after creating them if you want to tweak friction or restitution on them individually (be careful of infinite loops if the chain is a loop).
- Edge shapes can be dynamic. However, I don't really recommend it, aside from the novelty of it. They work fine if you turn on bullet mode for them, but they don't handle deep intersections very well, and they will only collide with polygons and circles. Edge shapes will never collide with each other. If you do decide to make dynamic edge shapes, don't forget to attach another shape to the same body, or maybe try messing around with b2MassData, since edge shapes always have zero mass and ignore the density property.
- There are three new TestBed examples, "StaticEdges", "PyramidStaticEdges", and "DynamicEdges".