(svn r5629) Simplify the test whether two bounding boxes overlap
authortron
Sat, 29 Jul 2006 10:18:59 +0000
changeset 4187 50b94420d9a2
parent 4186 853361bea03b
child 4188 c817518c79cc
(svn r5629) Simplify the test whether two bounding boxes overlap
viewport.c
--- a/viewport.c	Sat Jul 29 06:39:19 2006 +0000
+++ b/viewport.c	Sat Jul 29 10:18:59 2006 +0000
@@ -1048,18 +1048,12 @@
 
 				if (ps2->unk16 & 1) continue;
 
-				// Decide which sort order algorithm to use, based on whether the sprites have some overlapping area.
-				if ((
-							(ps2->xmin > ps->xmin && ps2->xmin < ps->xmax) ||
-							(ps2->xmax > ps->xmin && ps2->xmin < ps->xmax)
-						) && ( // overlap in X
-							(ps2->ymin > ps->ymin && ps2->ymin < ps->ymax) ||
-							(ps2->ymax > ps->ymin && ps2->ymin < ps->ymax)
-						) && ( // overlap in Y
-							(ps2->zmin > ps->zmin && ps2->zmin < ps->zmax) ||
-							(ps2->zmax > ps->zmin && ps2->zmin < ps->zmax)
-						)) { // overlap in Z
-					// Sprites overlap.
+				/* Decide which comparator to use, based on whether the bounding
+				 * boxes overlap
+				 */
+				if (ps->xmax > ps2->xmin && ps->xmin < ps2->xmax && // overlap in X?
+						ps->ymax > ps2->ymin && ps->ymin < ps2->ymax && // overlap in Y?
+						ps->zmax > ps2->zmin && ps->zmin < ps2->zmax) { // overlap in Z?
 					// Use X+Y+Z as the sorting order, so sprites nearer the bottom of the screen,
 					// and with higher Z elevation, draw in front.
 					// Here X,Y,Z are the coordinates of the "center of mass" of the sprite,