From 27cdef0075ba4b8424092c2bd13caaf61890c716 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 16 Aug 2016 23:17:45 +0100 Subject: [PATCH] WOOPS, did not mean to leave it in the rangecheck, now it works close to desired some complicated mathemagic leads to something which... seems CLOSE, but not perfectly accurate, so i think i need to tweak it more http://gfycat.com/JovialSpitefulAmericancrayfish for current behaviour --- src/r_things.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 44cb81132..5898eb21f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -913,8 +913,6 @@ static void R_DrawVisSprite(vissprite_t *vis) for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { #ifdef RANGECHECK - sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); - dc_iscale = 0xffffffffu / (unsigned)spryscale; texturecolumn = frac>>FRACBITS; @@ -924,6 +922,11 @@ static void R_DrawVisSprite(vissprite_t *vis) #else column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); #endif + if (vis->scalestep) + { + sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); + dc_iscale = FixedMul((0xffffffffu / (unsigned)spryscale), this_scale); + } if (vis->vflip) R_DrawFlippedMaskedColumn(column, patch->height); else @@ -1114,6 +1117,7 @@ static void R_ProjectSprite(mobj_t *thing) angle_t ang; fixed_t iscale; fixed_t scalestep = 0; // toast '16 + fixed_t leftoffset; //SoM: 3/17/2000 fixed_t gz, gzt; @@ -1199,7 +1203,7 @@ static void R_ProjectSprite(mobj_t *thing) if (1) //(flatsprite) { ang_scale = abs(FINESINE(ang>>ANGLETOFINESHIFT)); - scalestep = (FINECOSINE(ang>>ANGLETOFINESHIFT)); + //scalestep = (FINECOSINE(ang>>ANGLETOFINESHIFT)); } if (sprframe->rotate == SRF_SINGLE) @@ -1233,9 +1237,10 @@ static void R_ProjectSprite(mobj_t *thing) // calculate edges of the shape if (flip) - tx -= FixedMul(spritecachedinfo[lump].width-spritecachedinfo[lump].offset, FixedMul(this_scale, ang_scale)); + leftoffset = spritecachedinfo[lump].width-spritecachedinfo[lump].offset; else - tx -= FixedMul(spritecachedinfo[lump].offset, FixedMul(this_scale, ang_scale)); + leftoffset = spritecachedinfo[lump].offset; + tx -= FixedMul(leftoffset, FixedMul(this_scale, ang_scale)); x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS; // off the right side? @@ -1250,7 +1255,31 @@ static void R_ProjectSprite(mobj_t *thing) return; if (1) // (flatsprite) - yscale = yscale - (x2 - x1)*scalestep/2; + { + fixed_t yscale2; + INT32 range; + + tr_x = thing->x + FixedMul(-leftoffset, FINECOSINE(ang>>ANGLETOFINESHIFT)) - viewx; + tr_y = thing->y + FixedMul(-leftoffset, FINESINE(ang>>ANGLETOFINESHIFT)) - viewy; + gxt = FixedMul(tr_x, viewcos); + gyt = -FixedMul(tr_y, viewsin); + tz = gxt-gyt; + yscale = FixedDiv(projectiony, tz); + + leftoffset += spritecachedinfo[lump].width; + tr_x = thing->x + FixedMul(leftoffset, FINECOSINE(ang>>ANGLETOFINESHIFT)) - viewx; + tr_y = thing->y + FixedMul(leftoffset, FINESINE(ang>>ANGLETOFINESHIFT)) - viewy; + gxt = FixedMul(tr_x, viewcos); + gyt = -FixedMul(tr_y, viewsin); + tz = gxt-gyt; + yscale2 = FixedDiv(projectiony, tz); + + if (x2 > x1) + range = (x2 - x1); + else + range = 1; + scalestep = (yscale2 - yscale)/range; + } xscale = FixedMul(xscale, ang_scale);