diff options
author | tron <tron@openttd.org> | 2006-07-29 10:18:59 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-07-29 10:18:59 +0000 |
commit | ea51ace5f4fd1393b304670d7dbab0c1b837182a (patch) | |
tree | 1cdeba327701e81b7e421140470612872ef2d362 | |
parent | 2e443e2b6f860cb5ebad594d1b4297c7b1b0aef8 (diff) | |
download | openttd-ea51ace5f4fd1393b304670d7dbab0c1b837182a.tar.xz |
(svn r5629) Simplify the test whether two bounding boxes overlap
-rw-r--r-- | viewport.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/viewport.c b/viewport.c index 7f2876e45..4d94c05d5 100644 --- a/viewport.c +++ b/viewport.c @@ -1048,18 +1048,12 @@ static void ViewportSortParentSprites(ParentSpriteToDraw *psd[]) 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, |