From 648f1f0958e119978ddaf3d83e57efbdff1d0601 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Nov 2020 00:20:14 -0800 Subject: [PATCH 1/2] Revert "Do not sort sprite in front of plane if plane should render in front of sprite's plane" This reverts commit 0d6f329b1d9ecf3ba754a5affe80c669c56afc07. --- src/r_things.c | 37 ++----------------------------------- src/r_things.h | 1 - 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index df1946ba6..9702c7d3f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1230,32 +1230,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) return groundz; } -static void R_SetSpritePlaneHeights(vissprite_t *vis) -{ - ffloor_t *rover; - - fixed_t top; - fixed_t bot; - - vis->pt = vis->sector->floorheight; - vis->pb = vis->sector->ceilingheight; - - for (rover = vis->sector->ffloors; rover; rover = rover->next) - { - if (rover->flags & FF_EXISTS) - { - top = P_GetFFloorTopZAt (rover, vis->gx, vis->gy); - bot = P_GetFFloorBottomZAt (rover, vis->gx, vis->gy); - - if (top <= vis->gzt && top > vis->pt) - vis->pt = top; - - if (bot >= vis->gz && bot < vis->pb) - vis->pb = bot; - } - } -} - static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t tx, fixed_t tz) { vissprite_t *shadow; @@ -1344,8 +1318,6 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 shadow->scale = FixedMul(yscale, shadowyscale); shadow->sector = vis->sector; - shadow->pt = vis->pt; - shadow->pb = vis->pb; shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS); shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); shadow->cut = SC_ISSCALED|SC_SHADOW; //check this @@ -1845,9 +1817,6 @@ static void R_ProjectSprite(mobj_t *thing) vis->sector = thing->subsector->sector; vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS); vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); - - R_SetSpritePlaneHeights(vis); - vis->cut = cut; if (thing->subsector->sector->numlights) vis->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; @@ -2062,8 +2031,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, yscale))>>FRACBITS); vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, yscale))>>FRACBITS); - R_SetSpritePlaneHeights(vis); - iscale = FixedDiv(FRACUNIT, xscale); vis->startfrac = 0; @@ -2443,12 +2410,12 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps // bird: if any part of the sprite peeks in front the plane if (planecameraz < viewz) { - if (rover->pt >= planeobjectz && rover->gzt >= planeobjectz) + if (rover->gzt >= planeobjectz) continue; } else if (planecameraz > viewz) { - if (rover->pb <= planeobjectz && rover->gz <= planeobjectz) + if (rover->gz <= planeobjectz) continue; } diff --git a/src/r_things.h b/src/r_things.h index f95cd5c9e..400a63bcb 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -171,7 +171,6 @@ typedef struct vissprite_s // Precalculated top and bottom screen coords for the sprite. sector_t *sector; // The sector containing the thing. - fixed_t pt, pb; // plane heights, also for sorting against 3D floors INT16 sz, szt; spritecut_e cut; From 131d592bbfa896f131210e79ce458f0efa670d13 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 5 Nov 2020 04:55:01 -0800 Subject: [PATCH 2/2] Do not factor height into sprite thickseg sorting --- src/r_things.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 9702c7d3f..50eb222ae 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2448,7 +2448,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps } else if (r2->thickseg) { - fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; + //fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1) continue; @@ -2459,6 +2459,11 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if (scale <= rover->sortscale) continue; + // bird: Always sort sprites behind segs. This helps the plane + // sorting above too. Basically if the sprite gets sorted behind + // the seg here, it will be behind the plane too, since planes + // are added after segs in the list. +#if 0 topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy); topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy); botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy); @@ -2467,6 +2472,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if ((topplanecameraz > viewz && botplanecameraz < viewz) || (topplanecameraz < viewz && rover->gzt < topplaneobjectz) || (botplanecameraz > viewz && rover->gz > botplaneobjectz)) +#endif { entry = R_CreateDrawNode(NULL); (entry->prev = r2->prev)->next = entry;