diff --git a/src/r_things.c b/src/r_things.c index 0defa44e2ad762661980885fa44b75e8aae693c8..fed873fd6d37c3a33cfbd5a5e25022b6e5df883c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1066,7 +1066,7 @@ static void R_SplitSprite(vissprite_t *sprite) if (testheight <= sprite->gz) return; - cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->sortscale))>>FRACBITS); + cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->linkscale))>>FRACBITS); if (cutfrac < 0) continue; if (cutfrac > viewheight) @@ -1436,6 +1436,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t tx, tz; fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! fixed_t sortscale, sortsplat = 0; + fixed_t linkscale = 0; fixed_t sort_x = 0, sort_y = 0, sort_z; 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) { interpmobjstate_t tracer_interp = {0}; - fixed_t linkscale; thing = thing->tracer; @@ -1859,6 +1859,10 @@ static void R_ProjectSprite(mobj_t *thing) cut |= SC_LINKDRAW; } + else + { + linkscale = sortscale; + } // Calculate the splat's sortscale if (splat) @@ -2048,6 +2052,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->mobjflags = thing->flags; vis->sortscale = sortscale; vis->sortsplat = sortsplat; + vis->linkscale = linkscale; vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 vis->gx = interp.x; vis->gy = interp.y; @@ -2078,8 +2083,10 @@ static void R_ProjectSprite(mobj_t *thing) vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2; 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; if (thing->subsector->sector->numlights) diff --git a/src/r_things.h b/src/r_things.h index 6993f201ebfd26080fdb7b94cc1b068682db91e2..35eeb9ce161aab49c48ea439d1f77dc23c4f7dc1 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -159,8 +159,9 @@ typedef struct vissprite_s fixed_t startfrac; // horizontal position of x1 fixed_t xscale, scale; // projected horizontal and vertical scales 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 linkscale; // the sortscale for MF2_LINKDRAW sprites fixed_t scalestep; // only for paper sprites, 0 otherwise fixed_t paperoffset, paperdistance; // for paper sprites, offset/dist relative to the angle fixed_t xiscale; // negative if flipped