Box-Sphere Inaccurate Collision

Post Reply
Geometrian
Posts: 25
Joined: Sat Dec 03, 2011 8:37 pm
Contact:

Box-Sphere Inaccurate Collision

Post by Geometrian »

Hi,

When a box (btBoxShape) and a sphere (btSphereShape) collide, the collision is very good on faces, but inaccurate at edges/corners.

My tests show that on edges, the amount of penetration relative to the size of the box can range from 0.5% to 2.0%.

It seems to be independent of the time step--I tried down to 1/600th second steps with no improvement.

The only other thing I can find was this, which seems kinda related.

Thanks,
Ian
rtrius
Posts: 43
Joined: Sat May 26, 2012 1:09 am

Re: Box-Sphere Inaccurate Collision

Post by rtrius »

The patch in that thread has been applied(and seems to work well), but
is not enabled by default. If you are using Bullet 2.81+, it can be enabled
by adding '#define USE_BUGGY_SPHERE_BOX_ALGORITHM' at the top of
BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp.

I tried to replicate your results, but did not notice any issues
with a box of edge length 100m and a sphere of radius 1m.
Could you share more details about your configuration
(shape dimensions, mass, version), or provide a test case?

If your objects are fairly small (e.g. 1m box and 0.01m sphere),
it is possible that the collision margin (default 0.04m) could be causing
the issues. Shrinking the collision margin( btCollisionShape::setMargin() )
to around 0.0004 may help in such a case.

RBD's video provides a good explanation of collision margins,
see 3:50 in particular: http://youtu.be/BGAwRKPlpCw?t=3m50s
The left object with transparent exterior is the box shape. The collision
margin is subtracted from the user provided half extents resulting in rounded edges.
Geometrian
Posts: 25
Joined: Sat Dec 03, 2011 8:37 pm
Contact:

Re: Box-Sphere Inaccurate Collision

Post by Geometrian »

The collision margin was exactly the problem--I had no idea it even existed!

The scene I discovered it in was a sphere of radius 10cm rolling over boxes of size 1m on a side.

Thanks!
Post Reply