mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-19 07:51:43 +00:00
Fix drop shadow and rotsprite code to use SHORT()
This commit is contained in:
parent
e79d8c7896
commit
1528f2aef8
3 changed files with 32 additions and 26 deletions
|
@ -4158,7 +4158,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, gr_vissprite_t *spr, 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(thing->x);
|
fx = FIXED_TO_FLOAT(thing->x);
|
||||||
|
@ -4170,9 +4170,9 @@ static void HWR_DrawDropShadow(mobj_t *thing, gr_vissprite_t *spr, 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[0].x = shadowVerts[3].x = fx - offset;
|
shadowVerts[0].x = shadowVerts[3].x = fx - offset;
|
||||||
shadowVerts[2].x = shadowVerts[1].x = fx + offset;
|
shadowVerts[2].x = shadowVerts[1].x = fx + offset;
|
||||||
|
@ -5551,10 +5551,10 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
rotsprite = sprframe->rotsprite.patch[rot][rollangle];
|
rotsprite = sprframe->rotsprite.patch[rot][rollangle];
|
||||||
if (rotsprite != NULL)
|
if (rotsprite != NULL)
|
||||||
{
|
{
|
||||||
spr_width = rotsprite->width << FRACBITS;
|
spr_width = SHORT(rotsprite->width) << FRACBITS;
|
||||||
spr_height = rotsprite->height << FRACBITS;
|
spr_height = SHORT(rotsprite->height) << FRACBITS;
|
||||||
spr_offset = rotsprite->leftoffset << FRACBITS;
|
spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS;
|
||||||
spr_topoffset = rotsprite->topoffset << FRACBITS;
|
spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS;
|
||||||
// flip -> rotate, not rotate -> flip
|
// flip -> rotate, not rotate -> flip
|
||||||
flip = 0;
|
flip = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1231,9 +1231,9 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
if (!R_CheckIfPatch(lump))
|
if (!R_CheckIfPatch(lump))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
width = patch->width;
|
width = SHORT(patch->width);
|
||||||
height = patch->height;
|
height = SHORT(patch->height);
|
||||||
leftoffset = patch->leftoffset;
|
leftoffset = SHORT(patch->leftoffset);
|
||||||
|
|
||||||
// rotation pivot
|
// rotation pivot
|
||||||
px = SPRITE_XCENTER;
|
px = SPRITE_XCENTER;
|
||||||
|
@ -1348,7 +1348,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
newpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size);
|
newpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size);
|
||||||
{
|
{
|
||||||
newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px);
|
newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px);
|
||||||
newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py);
|
newpatch->topoffset = (newpatch->height / 2) + (SHORT(patch->topoffset) - py);
|
||||||
}
|
}
|
||||||
|
|
||||||
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
|
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
|
||||||
|
@ -1358,6 +1358,12 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
// P_PrecacheLevel
|
// P_PrecacheLevel
|
||||||
if (devparm) spritememory += size;
|
if (devparm) spritememory += size;
|
||||||
|
|
||||||
|
// convert everything to little-endian, for big-endian support
|
||||||
|
newpatch->width = SHORT(newpatch->width);
|
||||||
|
newpatch->height = SHORT(newpatch->height);
|
||||||
|
newpatch->leftoffset = SHORT(newpatch->leftoffset);
|
||||||
|
newpatch->topoffset = SHORT(newpatch->topoffset);
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
{
|
{
|
||||||
|
|
|
@ -890,7 +890,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||||
vis->x2 = vid.width-1;
|
vis->x2 = vid.width-1;
|
||||||
|
|
||||||
localcolfunc = (vis->cut & SC_VFLIP) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn;
|
localcolfunc = (vis->cut & SC_VFLIP) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn;
|
||||||
lengthcol = patch->height;
|
lengthcol = SHORT(patch->height);
|
||||||
|
|
||||||
// Split drawing loops for paper and non-paper to reduce conditional checks per sprite
|
// Split drawing loops for paper and non-paper to reduce conditional checks per sprite
|
||||||
if (vis->scalestep)
|
if (vis->scalestep)
|
||||||
|
@ -1235,8 +1235,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)
|
||||||
|
@ -1251,24 +1251,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();
|
||||||
shadow->patch = patch;
|
shadow->patch = patch;
|
||||||
|
@ -1283,8 +1283,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
|
||||||
shadow->dispoffset = vis->dispoffset - 5;
|
shadow->dispoffset = vis->dispoffset - 5;
|
||||||
shadow->gx = thing->x;
|
shadow->gx = thing->x;
|
||||||
shadow->gy = thing->y;
|
shadow->gy = thing->y;
|
||||||
shadow->gzt = shadow->pz + shadow->patch->height * shadowyscale / 2;
|
shadow->gzt = shadow->pz + SHORT(patch->height) * shadowyscale / 2;
|
||||||
shadow->gz = shadow->gzt - shadow->patch->height * shadowyscale;
|
shadow->gz = shadow->gzt - SHORT(patch->height) * shadowyscale;
|
||||||
shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale));
|
shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale));
|
||||||
if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
|
if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
|
||||||
shadow->texturemid = FixedMul(shadow->texturemid, ((skin_t *)thing->skin)->highresscale);
|
shadow->texturemid = FixedMul(shadow->texturemid, ((skin_t *)thing->skin)->highresscale);
|
||||||
|
@ -1305,7 +1305,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);
|
||||||
|
@ -1534,10 +1534,10 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
rotsprite = sprframe->rotsprite.patch[rot][rollangle];
|
rotsprite = sprframe->rotsprite.patch[rot][rollangle];
|
||||||
if (rotsprite != NULL)
|
if (rotsprite != NULL)
|
||||||
{
|
{
|
||||||
spr_width = rotsprite->width << FRACBITS;
|
spr_width = SHORT(rotsprite->width) << FRACBITS;
|
||||||
spr_height = rotsprite->height << FRACBITS;
|
spr_height = SHORT(rotsprite->height) << FRACBITS;
|
||||||
spr_offset = rotsprite->leftoffset << FRACBITS;
|
spr_offset = SHORT(rotsprite->leftoffset) << FRACBITS;
|
||||||
spr_topoffset = rotsprite->topoffset << FRACBITS;
|
spr_topoffset = SHORT(rotsprite->topoffset) << FRACBITS;
|
||||||
// flip -> rotate, not rotate -> flip
|
// flip -> rotate, not rotate -> flip
|
||||||
flip = 0;
|
flip = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue