New Primitives - b2ConcaveArcShape & b2ConvexArcShape

Just bumping this thread to let you know I've complete a second primitive, b2ConvexArcShape, which rounds off the library quite neatly. I've updated the first post with details. Let me know what you think.

Getting it half working was not so bad, but then I hit a major block trying to understand how box2d handles co-linear flat edges. Got it in the end though.
Very cool addition! I am getting ready to release a game that will make some good use of your concave arcs. They are working well for the most part, except I am having problems with rotation. They seem to rotate around their upper left corner, while b2PolyShapes rotate around the center. Also, when I set m_rotation on them after they are created it doesn't do anything. Your demos work fine with rotation though so I will have to look into this more.
brainclog wrote:
I am having problems with rotation. They seem to rotate around their upper left corner, while b2PolyShapes rotate around the center. Also, when I set m_rotation on them after they are created it doesn't do anything. Your demos work fine with rotation though so I will have to look into this more.


I am not sure why they are rotating wrong, virtually all the geometry of concave arcs is inherited from b2PolyShape. In any case when you rotate a poly it means you are rotating around the centroid (in 1.4.3. at least). This is usually close to the center of mass and thus fairly useful for polygons. However this is not really the case for concave arcs. I suggest you modify your code to include some translation, in such as way as to rotate around the center of mass.

Again, I'm not sure what the problem with m_rotation is? Bear in mind that you cannot set m_rotation directly, you have to use SetOriginPosition/SetCenterPosition, I think. Try swapping which one of those you are using, too. I never managed to understand the distinction between these, so it wouldn't be surprising if they don't behave exactly as they would for a polygon.

I don't have time to test this just now, but I think you can quickly swap concave arcs with their bounding poly by setting the type property in b2ConcaveArcDef to b2Shape.b2polyShape. You should try that, and see if you are getting the same problems.
Boosh! You're the man BorisTheBrave.
Just wondering... has anyone got the b2ConcaveArcShape & b2ConvexArcShape to work with 2.0.1? Any suggestions / guidance on how to go about hacking it in?
Awesome. I still plan on adding some shape types to 2.0.1, maybe we can collaborate on that, or at least warn each other about pitfalls. 😛

The demo with the concave arcs along the corners works beautifully. I love slinging a ball along the floor and watching it revolve around the room. But I noticed some jitter when the flat part of the convex arc is almost perpendicular to the floor...
Yeah, the arc isn't actually done correctly, iirc.
But I do get some odd jitter problems for all the shapes, I'm not sure if they were keeping the contact forces properly.

I know, I know I haven't touched this code in a long time, and I promised to get it up to 2.0. Well, I am still planning too, and soon now. I've got my last exam next week, and I'll be as free as a bird once more.

There are a few collaboration issues that I suppose need to be addressed:
  • There is the numbering of shape types, but I don't think that is a big deal.

  • Although there is a system in place for selecting the correct contact type when any two shapes touch, there is not a similar system for selecting which distance method to use between two shapes, just a bunch of ifs. I've already made changes to this, as the current way is messy for more than two shape types, though I don't have a version updated to the latest version of the source.

  • Precisely how to extend DebugDraw wasn't clear to me either. Adding a new method for each shape seems unappealing, as it makes more effort for implementing your own DebugDraw. But breaking down DebugDraw into vector operations (as so far everything can be drawn with circular arcs and lines) might not be appropriate for all uses.

  • Finally, we have to deal with shape collisions between two added shapes, at least assuming you want non-static ones. Though b2ConcaveArcShape is very cool and all, it was actually pretty hard just to write polygon collision code with it that worked reliably, so more complicated shapes may have worse problems. I might have to bump down the arc from a solid shape to a single curve, for simplicity, but this is unappealing. Then again, thanks to CCD, it is no longer necessary to deal with deep penetration issues, so my 1.4.3 code is probably "over robust".

Out of interest what shapes where you thinking of implementing?
Great! I was actually planning on trying to hack it in to 2.0.1 today... guess I'll wait. Glad this project's still alive.
Thanks for the tips. ^_^

I plan to add line segment shapes (again). They would be static-only, but they could let things pass through from one side (as in sidescroller platforms). And this time, I want to support something I call "corner hugging". See how Yoshi's momentum fails to carry him into the air after running up a hill? That's a GOOD thing in sidescrollers, though it is a tricky effect to achieve in a general physics engine like Box2D. It might involve modifications to the way that Box2D handles contacts, and I haven't figured out yet how I'm going to do it.
shaktool wrote:
And this time, I want to support something I call "corner hugging". See how Yoshi's momentum fails to carry him into the air after running up a hill? That's a GOOD thing in sidescrollers, though it is a tricky effect to achieve in a general physics engine like Box2D.


Yes please 😀 That'd be really useful.

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