I use the following function IsOverlap() to do exactly what Erin suggests. I simplified it a bit from my actual code, so there might be some minor syntax errors. If someone can simplify it even more, then please don't hold back.
EDIT: I just read that you only want to check a shape against the rest of the world, so my function is a bit overkill for you. But you can propably figure out how to do so yourself based on the example.
Code:
/// Returns true if the given body overlaps any other body in the world.
bool IsOverlap( const b2World* world, const b2Body* body )
{
CheckOverlapCallback callback( body );
world->QueryAABB( &callback, GetBodyAABB( body ) );
return callback.m_isOverlap;
}
/// Gets the combined AABB of all shapes of the given body.
b2AABB GetBodyAABB( const b2Body* body )
{
b2AABB result;
b2Transform trans = body->GetTransform();
const b2Fixture* first = body->GetFixtureList();
for( const b2Fixture* fixture = first; fixture; fixture = fixture->GetNext() )
{
b2AABB aabb;
fixture->GetShape()->ComputeAABB( &aabb, trans, 0 );
if( fixture == first )
result = aabb;
else
result.Combine( aabb );
}
return result;
}
/// Callback to check for overlap of given body.
struct CheckOverlapCallback : b2QueryCallback
{
CheckOverlapCallback( const b2Body* body ) :
m_body( body ), m_isOverlap( false ) {}
// override
bool ReportFixture( b2Fixture* fixture )
{
// Skip self.
if( fixture->GetBody() == m_body )
return true;
for( const b2Fixture* bodyFixture = m_body->GetFixtureList(); bodyFixture;
bodyFixture = bodyFixture->GetNext() )
{
if( b2TestOverlap( fixture->GetShape(), 0, bodyFixture->GetShape(), 0,
fixture->GetBody()->GetTransform(), m_body->GetTransform() ) )
{
m_isOverlap = true;
return false;
}
}
}
const b2Body* m_body;
bool m_isOverlap;
};