New Primitives - b2ConcaveArcShape & b2ConvexArcShape

Uploaded the typing. Plus made improved the efficiency of code as it no longer relies on TestPoint. Lemme know if I've broken it.

I wouldn't pray too hard for Erin to adopt this code. Having more than just polys and circles makes the code significantly harder to change, and we would get less new features as a consequence.
I think this is interesting work and Boris has done a great job.

It would be challenging to integrate this into 2.0 since continuous collision detection only works for convex shapes.

In 2.1 we'll have a mesh shape that will let you approximate an arc using line segments. CCD will work for this because each line segment is convex.

That said, once 2.0 comes out I'll be happy to accept patches for fully functional features.
Quote:
It would be challenging to integrate this into 2.0 since continuous collision detection only works for convex shapes.

If I'm correct, Bullet uses GIMPACT for non-convex collisions; do you happen to know if that works with CCD as well (and would it be worth doing a 2d port of it), or is there something fundamentally incompatible when it comes to CCD and non-convex shapes?
CCD can be implemented in many ways. Some people solve algebraic formulas to determine each vertex of one polytope collides the face of another polytope. Similar formulas are solved to determine when edges collide. Using this approach you can perform CCD between concave meshes. To extend this to arcs you would need to develop and solve algebraic formulas for vertex-vs-arc.

Box2D doesn't use these algebraic formulas. Instead it uses GJK to compute the distance between convex shapes and moves the shapes forward in time until the distance is very small, yet positive. GJK only works with convex shapes, so arcs wouldn't work.

CCD-GJK can be made to work with concave triangle/line segment meshes by considering each potentially colliding triange/line segment (which are individually convex). Further, the continuous physics algorithm used by Box2D requires at least one of the colliding convex shapes to have non-zero volume. So mesh vs mesh wouldn't work because line segments have zero volume.
Ah, you answered my question before I asked it. So essentially, the extra code required to support CCD is that contacts accurately estimate the the minimal distance between two shapes? Or do we actually require the shapes to be convex after that as well.

It doesn't seem intractable to calculate that distance for a concave arc, if at least by reducing them to 0-volume shapes like line segments.

I cannot help but feel I've misunderstood though, or underestimated the problem. GJC is for arbitrary convex shapes, there are surely better approaches for polys, circles and line segments?
You have a point. All I would need is the distance. Also, you are correct, I don't use GJK for all distance queries. Obviously GJK is overkill for circle-vs-circle.

So yeah, arcs could work with CCD if a distance query is provided for arc-circle, arc-polygon, etc.
Ok, I think it's doable to get the correct distance, by overriding GJK in certain circumstances. But the code would have significant overlap with my previous code. Have you considered merging the two sorts of queries (distance queries and penetration queries) in some way? Like making distances tests part of the contact classes? They share a lot of similar structure.
GJK can't be used to compute penetration. On the flip side the separating axis test (SAT) doesn't provide the true distance in some cases (where the closest points are vertices).

Also for polygon-vs-polygon overlap it is not just a matter of computing the pentration, I perform clipping to get multiple contact points and I identify the features involved to support warm starting the solver.
Hi, from the demos I saw the arcs "inside" the rectangle.
Any chance of having something like a half a circle, convex and concave in one...?

Btw, this is a truly great feat to the engine... 😉
I am working on a convex equivalent to b2ConcaveArcShape (except that it has only one straight edge). But despite superficial similarities, they are very different to implement, so there will not be a generalized object that can handle both sorts of curves. Nor will I be doing a "mesh" equivalent, i.e. just a curve floating on it's own rather than the border of some solid object.
This means thin, wide arcs, like rainbows, will require a lot of spurious edges to create properly. I do not see this as a common use case.

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