Edge Shapes for C++ (Merged!)

Part of the annoyingness of trying to make double-sided edges is the continuous physics Time-Of-Impact calculations, which need to find the distance between shapes, plus a little extra distance. Polygons handle this by creating an extra set of vertices which are shrunken a little bit towards the center, called "core vertices", and it uses these instead of the normal vertices when calculating distance. I did the same thing with EdgeShapes, meaning there's a hidden "core edge" which is offset slightly on the "wrong" side of the edge. If you want EdgeShapes to be double sided, then this probably won't work, and instead you should just use the normal vertices of EdgeShapes and then add a small distance onto the result of those calculations before returning it. This technique MIGHT actually be preferable anyway, though I'm not sure yet.

But perhaps more problematic is dealing with convex corners of EdgeShapes, like a cliff at the end of a platform. When my character walks over a cliff, I don't want my toes to bump into the vertical wall below the cliff before I actually fall. But Box2D never resolves overlaps completely, so my feet are slightly embedded in the ground already and it's likely that I'll stub my toe on the inner side of the vertical edge instead of gliding over the cliff and then falling on the other side.

There's probably a way to solve these problems, but the details will likely be tricky and require lots of testing. Perhaps it would be okay to increase the actual thickness of EdgeShapes slightly to avoid the above problems, or perhaps we could use information about the angle between edges at corners to avoid the problems. I welcome contributions.

If you want, you could just create a pair of EdgeShapes for every edge in your map, but offset slightly from each other so that they simulate thickness. This solution would not require any modification to Box2D.
That was my first thought to create a pair of back-to-back Edges but it doesn't behave quite like I'd expect; it's very easy for my other shapes to get "stuck" between the Edges, as if any slight penetration through one Edge gets grabbed by the wrong side of the other Edge and the fighting of the two forces just cause the shape to freeze.
The edges should probably be separated by MORE than two times Box2D.Common.b2Settings.b2_toiSlop. Let's say around three times b2_toiSlop. And, of course, the "correct" sides of the edges should be facing away from each other.

EDIT: If the Time-Of-Impact issue is resolved, then the offset between the pairs of edges could be reduced to something much closer to Box2D.Common.b2Settings.b2_linearSlop
This did help quite a bit, my shapes are not getting stuck on top of back-to-back Edges quite so often if I separate them by 3 * b2_toiSlop = 0.12. I'm still having a bit of trouble in my Editor since I use b2Body::SetXForm() to move bodies around, which makes it easy to force a shape on top of a pair of b2b Edges causing it to stick even when they are separated by 0.12, but that is somewhat unrelated to Edge implementation.

One of my favorite things about an Edge in fact is that it does have 0 thickness, this makes it very easy to line them up with other shapes; if my Edge runs along the X-axis, then it actually does run along the X-axis, rather than slightly above/below it. Of course this is the major problem with using a minimum-thickness polygon to represent an Edge; b2b Edges also suffer from this.

Overall I'm beginning to think that 1-sided Edges really are ok now I've found a nice way to represent them graphically. The only place they seem to behave in unexpected ways is when 2 unchained Edges are back-to-back, such as long, thin needle shapes, where the "pull" of the backside of the opposite Edge yanks a shape through to the other side. A noob question, but is there a way to tweak this "pulling" force, or is this inherent to the way that collisions are resolved?
The "pulling force" isn't actually a force, because it does not actually affect velocity, it's just trying to resolve perceived deep overlaps. It's a result of the position solver. I can't think of a good way to tweak it.
RaycastOne doesn't seem to work with edge shapes?? Please say I'm mistaken.
I have a build error. The b2Body::CreateShape function no longer works. Neither does the b2World::Step. When I checked the headers of each class, the functions weren't even there. What's up with that?

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