mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r5629) Simplify the test whether two bounding boxes overlap
This commit is contained in:
parent
2e443e2b6f
commit
ea51ace5f4
18
viewport.c
18
viewport.c
@ -1048,18 +1048,12 @@ static void ViewportSortParentSprites(ParentSpriteToDraw *psd[])
|
|||||||
|
|
||||||
if (ps2->unk16 & 1) continue;
|
if (ps2->unk16 & 1) continue;
|
||||||
|
|
||||||
// Decide which sort order algorithm to use, based on whether the sprites have some overlapping area.
|
/* Decide which comparator to use, based on whether the bounding
|
||||||
if ((
|
* boxes overlap
|
||||||
(ps2->xmin > ps->xmin && ps2->xmin < ps->xmax) ||
|
*/
|
||||||
(ps2->xmax > ps->xmin && ps2->xmin < ps->xmax)
|
if (ps->xmax > ps2->xmin && ps->xmin < ps2->xmax && // overlap in X?
|
||||||
) && ( // overlap in X
|
ps->ymax > ps2->ymin && ps->ymin < ps2->ymax && // overlap in Y?
|
||||||
(ps2->ymin > ps->ymin && ps2->ymin < ps->ymax) ||
|
ps->zmax > ps2->zmin && ps->zmin < ps2->zmax) { // overlap in Z?
|
||||||
(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.
|
|
||||||
// Use X+Y+Z as the sorting order, so sprites nearer the bottom of the screen,
|
// Use X+Y+Z as the sorting order, so sprites nearer the bottom of the screen,
|
||||||
// and with higher Z elevation, draw in front.
|
// and with higher Z elevation, draw in front.
|
||||||
// Here X,Y,Z are the coordinates of the "center of mass" of the sprite,
|
// Here X,Y,Z are the coordinates of the "center of mass" of the sprite,
|
||||||
|
Loading…
Reference in New Issue
Block a user