Capsule shape has unwanted collision

Hi all,

After some problems with box shapes colliding on "flat" ground, and after reading this thread:

viewtopic.php?f=3&t=3048&start=10

I have implemented a capsule shape as suggested using a box and two circles (as suggested here
viewtopic.php?t=5183)

However I am still getting some unwanted collisions with my capsule shape.

The diagram below shows the problem:
Attachment:
capsule1.png
capsule1.png [ 1.28 KiB | Viewed 312 times ]


The arrow indicates where the collision is taking place. Basically my game character (represented by the capsule) can sometimes come to rest on the corner of a "wall" (static body) if the corner of the box shape within the capsule collides with the corner of the wall.

Initially I thought to reduce slightly the width of the box to allow the circles to protrude ever so slightly beyond the width of the box, however this leads to the opposite problem as displayed below:
Attachment:
capsule2.png
capsule2.png [ 1.29 KiB | Viewed 312 times ]


In this case the character comes to rest when the under-side of the top circle collides with the wall.

I have tried all sorts of crazy solutions like disabling contacts that impact on the horizontal edges of the box (which doesn't work BTW as it just leads to the second case above) but I just can't seem to figure an "elegant" solution.

I understand that there are no plans to implement a capsule shape (and I imagine this would cause some significant complexities where collision detection is concerned), but I'm wondering if there is some other genius solution to this?

Thanks.
The SVN version of b2LoopShape has adjacency information to let boxes move smoothly.

In your second example, the character must be pushing hard to the right because the contact normal on the bottom of the upper circle should be pointing left and up slightly. This can be cured by recognizing that there is no support on the bottom circle and driving the character downward at a rate that is stronger than than the horizontal steering.

If you can't resolve that, you might try the new b2LoopShape or try a hexagon shape with a pointy bottom.
Thanks Erin,

Unfortunately after the changes I have made to overcome some limitations on Android, together with the additions I have made to solve friction modifications, I'm a bit scared to do an SVN update as I'll need to re-implement these changes.

Bad strategy I know, but on the Android limitation I had little choice and the friction filtering is something I really needed.

At some point I will have to merge with SVN but I'm just trying to put it off as long as possible.

I think for now I will just have to live with it. It's not really a deal-breaker, just a bit annoying for the player.

P.S.

On the friction modification, I have implemented a "b2FrictionMixer" class which just has one method (float32 MixFriction(b2Contact* contact)). I then pass a pointer to an instance of this into the constructor for the b2ContactSolver, in which I simply delegate to the b2FrictionMixer IF it's available. Otherwise it just defers to default (current) behavior. This means I can set whatever friction logic I like into box2d without affecting default behavior, however it has meant changing a few b2d classes, namely b2ContactSolver, b2Island and b2World, to accept my b2FrictionMixer as a constructor argument.

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