Getting interpenetration during collision?

Once I detect a collision through a contact listener, is there a way to know how much penetration there is between the two objects (or how far apart their colliding points are)?

Here's the situation: In my game I have a setup phase where the user can move items around. We don't want them to interpenetrate, so if they collide, I mark them as invalid positions. Unfortunately, right now Box2D reports a collision even if the objects are not interpenetrating but are within the slop distance. Ideally, I'd like the user to be able to get them very close, but not quite interpenetrating.

Any thoughts?
You can use this modified version of b2TestOverlap:
Code:
bool b2TestOverlapZeroRadius(   const b2Shape* shapeA, int32 indexA,
               const b2Shape* shapeB, int32 indexB,
               const b2Transform& xfA, const b2Transform& xfB)
{
   b2DistanceInput input;
   input.proxyA.Set(shapeA, indexA);
   input.proxyB.Set(shapeB, indexB);
   input.transformA = xfA;
   input.transformB = xfB;
   input.useRadii = false; // modified here

   b2SimplexCache cache;
   cache.count = 0;

   b2DistanceOutput output;

   b2Distance(&output, &cache, &input);

   return output.distance < 10.0f * b2_epsilon;
}


For circles you'll want to use the radius, so you'd need to account for that. Alternatively, you could set the polygon radius to zero while in edit mode.

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