Game Development Reference
In-Depth Information
Figure 7.6
The four cases where two 2D AABBs definitely
cannot
intersect.
Ifanyofthefourcasesaretrue,itmeanstheAABBsdonotintersect,andtherefore
the intersection function should return false. This means that the return statement
should be the logical negation of the four comparison statements, as in
Listing 7.2
.
Listing 7.2
AABB versus AABB Intersection
function
AABBIntersection(
AABB2D
a
,
AABB2D
b
)
bool
test
= (
a
.
max
.
x
<
b
.
min
.
x
) || (
b
.
max
.
x
<
a
.
min
.
x
) ||