SHORT fixes from vanilla for shadows

This commit is contained in:
Sally Coolatta 2020-07-29 21:28:09 -04:00
parent 0060a30bc4
commit 72bfbefad3
2 changed files with 11 additions and 11 deletions

View file

@ -2860,7 +2860,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
HWR_GetPatch(gpatch); HWR_GetPatch(gpatch);
scalemul = FixedMul(FRACUNIT - floordiff/640, scale); scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height); scalemul = FixedMul(scalemul, (thing->radius*2) / SHORT(gpatch->height));
fscale = FIXED_TO_FLOAT(scalemul); fscale = FIXED_TO_FLOAT(scalemul);
fx = FIXED_TO_FLOAT(thingxpos); fx = FIXED_TO_FLOAT(thingxpos);
@ -2872,9 +2872,9 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
// 0--1 // 0--1
if (thing && fabsf(fscale - 1.0f) > 1.0E-36f) if (thing && fabsf(fscale - 1.0f) > 1.0E-36f)
offset = (gpatch->height/2) * fscale; offset = (SHORT(gpatch->height)/2) * fscale;
else else
offset = (float)(gpatch->height/2); offset = (float)(SHORT(gpatch->height)/2);
shadowVerts[2].x = shadowVerts[3].x = fx + offset; shadowVerts[2].x = shadowVerts[3].x = fx + offset;
shadowVerts[1].x = shadowVerts[0].x = fx - offset; shadowVerts[1].x = shadowVerts[0].x = fx - offset;

View file

@ -1295,8 +1295,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
yscale = FixedDiv(projectiony, tz); yscale = FixedDiv(projectiony, tz);
shadowxscale = FixedMul(thing->radius*2, scalemul); shadowxscale = FixedMul(thing->radius*2, scalemul);
shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(floorz - viewz), tz)); shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(floorz - viewz), tz));
shadowyscale = min(shadowyscale, shadowxscale) / patch->height; shadowyscale = min(shadowyscale, shadowxscale) / SHORT(patch->height);
shadowxscale /= patch->width; shadowxscale /= SHORT(patch->width);
shadowskew = 0; shadowskew = 0;
if (floorslope) if (floorslope)
@ -1311,24 +1311,24 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
//CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope);
if (viewz < floorz) if (viewz < floorz)
shadowyscale += FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); shadowyscale += FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope);
else else
shadowyscale -= FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); shadowyscale -= FixedMul(FixedMul(thing->radius*2 / SHORT(patch->height), scalemul), zslope);
shadowyscale = abs(shadowyscale); shadowyscale = abs(shadowyscale);
shadowskew = xslope; shadowskew = xslope;
} }
tx -= patch->width * shadowxscale/2; tx -= SHORT(patch->width) * shadowxscale/2;
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
if (x1 >= viewwidth) return; if (x1 >= viewwidth) return;
tx += patch->width * shadowxscale; tx += SHORT(patch->width) * shadowxscale;
x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--;
if (x2 < 0 || x2 <= x1) return; if (x2 < 0 || x2 <= x1) return;
if (shadowyscale < FRACUNIT/patch->height) return; // fix some crashes? if (shadowyscale < FRACUNIT/SHORT(patch->height)) return; // fix some crashes?
shadow = R_NewVisSprite(); shadow = R_NewVisSprite();
@ -1379,7 +1379,7 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
shadow->startfrac = 0; shadow->startfrac = 0;
//shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2); //shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2);
shadow->xiscale = (patch->width<<FRACBITS)/(x2-x1+1); // fuck it shadow->xiscale = (SHORT(patch->width)<<FRACBITS)/(x2-x1+1); // fuck it
if (shadow->x1 > x1) if (shadow->x1 > x1)
shadow->startfrac += shadow->xiscale*(shadow->x1-x1); shadow->startfrac += shadow->xiscale*(shadow->x1-x1);