Since the overlaps function relies on the volume of the intersection of the two AABBs, which is 0 in this case, the assert fails.
This can happen in practice, if you have an axis aligned triangle, create its AABB and use it to "early out" of an intersection test.
One solution could be to only check if the intersection AABB is valid.
/// Returns true if the two AABBs have any overlap.
bool overlaps(AABB b)
{
b.intersection(*this);
return b.valid();
}
However, this would return true for "touching" AABBs. Depending on the definition of "overlaps", this might be a problem.
The AABB::overlaps function misses overlaps when one of the AABBs is 0 in one dimension. Example:
Since the
overlaps
function relies on the volume of the intersection of the two AABBs, which is 0 in this case, the assert fails. This can happen in practice, if you have an axis aligned triangle, create its AABB and use it to "early out" of an intersection test.One solution could be to only check if the intersection AABB is valid.
However, this would return true for "touching" AABBs. Depending on the definition of "overlaps", this might be a problem.
Would love to hear your thoughts on that.