Handle sorting against water FOFs properly

This commit is contained in:
Sally Coolatta 2022-11-04 21:33:41 -04:00
parent ee9ebe6c54
commit fa10530d37
2 changed files with 13 additions and 5 deletions

View file

@ -1066,7 +1066,7 @@ static void R_SplitSprite(vissprite_t *sprite)
if (testheight <= sprite->gz) if (testheight <= sprite->gz)
return; return;
cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->sortscale))>>FRACBITS); cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->linkscale))>>FRACBITS);
if (cutfrac < 0) if (cutfrac < 0)
continue; continue;
if (cutfrac > viewheight) if (cutfrac > viewheight)
@ -1436,6 +1436,7 @@ static void R_ProjectSprite(mobj_t *thing)
fixed_t tx, tz; fixed_t tx, tz;
fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!!
fixed_t sortscale, sortsplat = 0; fixed_t sortscale, sortsplat = 0;
fixed_t linkscale = 0;
fixed_t sort_x = 0, sort_y = 0, sort_z; fixed_t sort_x = 0, sort_y = 0, sort_z;
INT32 x1, x2; INT32 x1, x2;
@ -1827,7 +1828,6 @@ static void R_ProjectSprite(mobj_t *thing)
if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) // toast 16/09/16 (SYMMETRY) if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) // toast 16/09/16 (SYMMETRY)
{ {
interpmobjstate_t tracer_interp = {0}; interpmobjstate_t tracer_interp = {0};
fixed_t linkscale;
thing = thing->tracer; thing = thing->tracer;
@ -1859,6 +1859,10 @@ static void R_ProjectSprite(mobj_t *thing)
cut |= SC_LINKDRAW; cut |= SC_LINKDRAW;
} }
else
{
linkscale = sortscale;
}
// Calculate the splat's sortscale // Calculate the splat's sortscale
if (splat) if (splat)
@ -2048,6 +2052,7 @@ static void R_ProjectSprite(mobj_t *thing)
vis->mobjflags = thing->flags; vis->mobjflags = thing->flags;
vis->sortscale = sortscale; vis->sortscale = sortscale;
vis->sortsplat = sortsplat; vis->sortsplat = sortsplat;
vis->linkscale = linkscale;
vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15
vis->gx = interp.x; vis->gx = interp.x;
vis->gy = interp.y; vis->gy = interp.y;
@ -2078,8 +2083,10 @@ static void R_ProjectSprite(mobj_t *thing)
vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2; vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2;
vis->sector = thing->subsector->sector; 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); // Using linkscale here improves cut detection for LINKDRAW.
vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, linkscale))>>FRACBITS);
vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, linkscale))>>FRACBITS);
vis->cut = cut; vis->cut = cut;
if (thing->subsector->sector->numlights) if (thing->subsector->sector->numlights)

View file

@ -159,8 +159,9 @@ typedef struct vissprite_s
fixed_t startfrac; // horizontal position of x1 fixed_t startfrac; // horizontal position of x1
fixed_t xscale, scale; // projected horizontal and vertical scales fixed_t xscale, scale; // projected horizontal and vertical scales
fixed_t thingscale; // the object's scale fixed_t thingscale; // the object's scale
fixed_t sortscale; // sortscale only differs from scale for paper sprites, floor sprites, and MF2_LINKDRAW fixed_t sortscale; // sortscale only differs from scale for paper sprites and floor sprites
fixed_t sortsplat; // the sortscale from behind the floor sprite fixed_t sortsplat; // the sortscale from behind the floor sprite
fixed_t linkscale; // the sortscale for MF2_LINKDRAW sprites
fixed_t scalestep; // only for paper sprites, 0 otherwise fixed_t scalestep; // only for paper sprites, 0 otherwise
fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle
fixed_t xiscale; // negative if flipped fixed_t xiscale; // negative if flipped