mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-22 20:02:03 +00:00
Merge branch 'interpolate-hitbox-scaling' into 'next'
Interpolate Hitboxes when Scaling Mobjs See merge request STJr/SRB2!2124
This commit is contained in:
commit
d42a96263b
5 changed files with 76 additions and 70 deletions
|
@ -3595,7 +3595,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
floordiff = abs((flip < 0 ? thing->height : 0) + interp.z - groundz);
|
floordiff = abs((flip < 0 ? interp.height : 0) + interp.z - groundz);
|
||||||
|
|
||||||
alpha = floordiff / (4*FRACUNIT) + 75;
|
alpha = floordiff / (4*FRACUNIT) + 75;
|
||||||
if (alpha >= 255) return;
|
if (alpha >= 255) return;
|
||||||
|
@ -3606,9 +3606,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, (interp.radius*2) / gpatch->height);
|
||||||
if ((thing->scale != thing->old_scale) && (thing->scale >= FRACUNIT/1024)) // Interpolate shadows when scaling mobjs
|
|
||||||
scalemul = FixedMul(scalemul, FixedDiv(interp.scale, thing->scale));
|
|
||||||
|
|
||||||
fscale = FIXED_TO_FLOAT(scalemul);
|
fscale = FIXED_TO_FLOAT(scalemul);
|
||||||
fx = FIXED_TO_FLOAT(interp.x);
|
fx = FIXED_TO_FLOAT(interp.x);
|
||||||
|
@ -3720,7 +3718,7 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts
|
||||||
|
|
||||||
if (P_MobjFlip(spr->mobj) == -1)
|
if (P_MobjFlip(spr->mobj) == -1)
|
||||||
{
|
{
|
||||||
basey = FIXED_TO_FLOAT(interp.z + spr->mobj->height);
|
basey = FIXED_TO_FLOAT(interp.z + interp.height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4055,32 +4053,32 @@ static void HWR_DrawBoundingBox(gl_vissprite_t *vis)
|
||||||
// repeat this 4 times (overhead)
|
// repeat this 4 times (overhead)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// 17 20 21 11
|
// 15 16 17 09
|
||||||
// 16 15 14 10
|
// 14 13 12 08
|
||||||
// 27 22 *--* 07 12
|
// 23 18 *--* 07 10
|
||||||
// | |
|
// | |
|
||||||
// 26 23 *--* 06 13
|
// 22 19 *--* 06 11
|
||||||
// 24 00 01 02
|
// 20 00 01 02
|
||||||
// 25 05 04 03
|
// 21 05 04 03
|
||||||
//
|
//
|
||||||
|
|
||||||
v[000].x = v[005].x = v[015].x = v[016].x = v[017].x = v[020].x =
|
v[ 0].x = v[ 5].x = v[13].x = v[14].x = v[15].x = v[16].x =
|
||||||
v[022].x = v[023].x = v[024].x = v[025].x = v[026].x = v[027].x = vis->x1; // west
|
v[18].x = v[19].x = v[20].x = v[21].x = v[22].x = v[23].x = vis->x1; // west
|
||||||
|
|
||||||
v[001].x = v[002].x = v[003].x = v[004].x = v[006].x = v[007].x =
|
v[ 1].x = v[ 2].x = v[ 3].x = v[ 4].x = v[ 6].x = v[ 7].x =
|
||||||
v[010].x = v[011].x = v[012].x = v[013].x = v[014].x = v[021].x = vis->x2; // east
|
v[ 8].x = v[ 9].x = v[10].x = v[11].x = v[12].x = v[17].x = vis->x2; // east
|
||||||
|
|
||||||
v[000].z = v[001].z = v[002].z = v[003].z = v[004].z = v[005].z =
|
v[ 0].z = v[ 1].z = v[ 2].z = v[ 3].z = v[ 4].z = v[ 5].z =
|
||||||
v[006].z = v[013].z = v[023].z = v[024].z = v[025].z = v[026].z = vis->z1; // south
|
v[ 6].z = v[11].z = v[19].z = v[20].z = v[21].z = v[22].z = vis->z1; // south
|
||||||
|
|
||||||
v[007].z = v[010].z = v[011].z = v[012].z = v[014].z = v[015].z =
|
v[ 7].z = v[ 8].z = v[ 9].z = v[10].z = v[12].z = v[13].z =
|
||||||
v[016].z = v[017].z = v[020].z = v[021].z = v[022].z = v[027].z = vis->z2; // north
|
v[14].z = v[15].z = v[16].z = v[17].z = v[18].z = v[23].z = vis->z2; // north
|
||||||
|
|
||||||
v[000].y = v[001].y = v[002].y = v[006].y = v[007].y = v[010].y =
|
v[ 0].y = v[ 1].y = v[ 2].y = v[ 6].y = v[ 7].y = v[ 8].y =
|
||||||
v[014].y = v[015].y = v[016].y = v[022].y = v[023].y = v[024].y = vis->gz; // bottom
|
v[12].y = v[13].y = v[14].y = v[18].y = v[19].y = v[20].y = vis->gz; // bottom
|
||||||
|
|
||||||
v[003].y = v[004].y = v[005].y = v[011].y = v[012].y = v[013].y =
|
v[ 3].y = v[ 4].y = v[ 5].y = v[ 9].y = v[10].y = v[11].y =
|
||||||
v[017].y = v[020].y = v[021].y = v[025].y = v[026].y = v[027].y = vis->gzt; // top
|
v[15].y = v[16].y = v[17].y = v[21].y = v[22].y = v[23].y = vis->gzt; // top
|
||||||
|
|
||||||
Surf.PolyColor = V_GetColor(R_GetBoundingBoxColor(vis->mobj));
|
Surf.PolyColor = V_GetColor(R_GetBoundingBoxColor(vis->mobj));
|
||||||
|
|
||||||
|
@ -5326,7 +5324,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
}
|
}
|
||||||
|
|
||||||
groundz = R_GetShadowZ(thing, NULL);
|
groundz = R_GetShadowZ(thing, NULL);
|
||||||
floordiff = abs(((thing->eflags & MFE_VERTICALFLIP) ? caster->height : 0) + casterinterp.z - groundz);
|
floordiff = abs(((thing->eflags & MFE_VERTICALFLIP) ? casterinterp.height : 0) + casterinterp.z - groundz);
|
||||||
|
|
||||||
shadowheight = FIXED_TO_FLOAT(floordiff);
|
shadowheight = FIXED_TO_FLOAT(floordiff);
|
||||||
shadowscale = FIXED_TO_FLOAT(FixedMul(FRACUNIT - floordiff/640, casterinterp.scale));
|
shadowscale = FIXED_TO_FLOAT(FixedMul(FRACUNIT - floordiff/640, casterinterp.scale));
|
||||||
|
@ -5378,10 +5376,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
if (vflip)
|
if (vflip)
|
||||||
{
|
{
|
||||||
if (thing->scale != thing->old_scale) // Interpolate heights in reverse gravity when scaling mobjs
|
gz = FIXED_TO_FLOAT(interp.z + interp.height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale);
|
||||||
gz = FIXED_TO_FLOAT(interp.z + FixedMul(thing->height, FixedDiv(interp.scale, thing->scale))) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale);
|
|
||||||
else
|
|
||||||
gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale);
|
|
||||||
gzt = gz + (FIXED_TO_FLOAT(spr_height) * this_yscale);
|
gzt = gz + (FIXED_TO_FLOAT(spr_height) * this_yscale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -5687,7 +5682,6 @@ static void HWR_ProjectBoundingBox(mobj_t *thing)
|
||||||
gl_vissprite_t *vis;
|
gl_vissprite_t *vis;
|
||||||
float tr_x, tr_y;
|
float tr_x, tr_y;
|
||||||
float tz;
|
float tz;
|
||||||
float rad;
|
|
||||||
|
|
||||||
if (!thing)
|
if (!thing)
|
||||||
return;
|
return;
|
||||||
|
@ -5722,15 +5716,13 @@ static void HWR_ProjectBoundingBox(mobj_t *thing)
|
||||||
tr_x += gl_viewx;
|
tr_x += gl_viewx;
|
||||||
tr_y += gl_viewy;
|
tr_y += gl_viewy;
|
||||||
|
|
||||||
rad = FIXED_TO_FLOAT(thing->radius);
|
|
||||||
|
|
||||||
vis = HWR_NewVisSprite();
|
vis = HWR_NewVisSprite();
|
||||||
vis->x1 = tr_x - rad;
|
vis->x1 = tr_x - FIXED_TO_FLOAT(interp.radius);
|
||||||
vis->x2 = tr_x + rad;
|
vis->x2 = tr_x + FIXED_TO_FLOAT(interp.radius);
|
||||||
vis->z1 = tr_y - rad;
|
vis->z1 = tr_y - FIXED_TO_FLOAT(interp.radius);
|
||||||
vis->z2 = tr_y + rad;
|
vis->z2 = tr_y + FIXED_TO_FLOAT(interp.radius);
|
||||||
vis->gz = FIXED_TO_FLOAT(interp.z);
|
vis->gz = FIXED_TO_FLOAT(interp.z);
|
||||||
vis->gzt = vis->gz + FIXED_TO_FLOAT(thing->height);
|
vis->gzt = vis->gz + FIXED_TO_FLOAT(interp.height);
|
||||||
vis->mobj = thing;
|
vis->mobj = thing;
|
||||||
|
|
||||||
vis->precip = false;
|
vis->precip = false;
|
||||||
|
|
|
@ -1585,12 +1585,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
p.y = FIXED_TO_FLOAT(interp.y)+md2->offset;
|
p.y = FIXED_TO_FLOAT(interp.y)+md2->offset;
|
||||||
|
|
||||||
if (flip)
|
if (flip)
|
||||||
{
|
p.z = FIXED_TO_FLOAT(interp.z + interp.height);
|
||||||
if (spr->mobj->scale != spr->mobj->old_scale) // Interpolate heights in reverse gravity when scaling mobjs
|
|
||||||
p.z = FIXED_TO_FLOAT(interp.z + FixedMul(spr->mobj->height, FixedDiv(interp.scale, spr->mobj->scale)));
|
|
||||||
else
|
|
||||||
p.z = FIXED_TO_FLOAT(interp.z + spr->mobj->height);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
p.z = FIXED_TO_FLOAT(interp.z);
|
p.z = FIXED_TO_FLOAT(interp.z);
|
||||||
|
|
||||||
|
@ -1626,8 +1621,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
|
||||||
p.roll = true;
|
p.roll = true;
|
||||||
|
|
||||||
// rotation pivot
|
// rotation pivot
|
||||||
p.centerx = FIXED_TO_FLOAT(spr->mobj->radius / 2);
|
p.centerx = FIXED_TO_FLOAT(interp.radius / 2);
|
||||||
p.centery = FIXED_TO_FLOAT(spr->mobj->height / 2);
|
p.centery = FIXED_TO_FLOAT(interp.height / 2);
|
||||||
|
|
||||||
// rotation axes relative to camera
|
// rotation axes relative to camera
|
||||||
p.rollx = FIXED_TO_FLOAT(FINECOSINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT));
|
p.rollx = FIXED_TO_FLOAT(FINECOSINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT));
|
||||||
|
|
20
src/r_fps.c
20
src/r_fps.c
|
@ -292,6 +292,8 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
||||||
out->y = mobj->y;
|
out->y = mobj->y;
|
||||||
out->z = mobj->z;
|
out->z = mobj->z;
|
||||||
out->scale = mobj->scale;
|
out->scale = mobj->scale;
|
||||||
|
out->radius = mobj->radius;
|
||||||
|
out->height = mobj->height;
|
||||||
out->subsector = mobj->subsector;
|
out->subsector = mobj->subsector;
|
||||||
out->angle = mobj->player ? mobj->player->drawangle : mobj->angle;
|
out->angle = mobj->player ? mobj->player->drawangle : mobj->angle;
|
||||||
out->pitch = mobj->pitch;
|
out->pitch = mobj->pitch;
|
||||||
|
@ -307,10 +309,22 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
||||||
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
|
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
|
||||||
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
||||||
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
||||||
out->scale = mobj->resetinterp ? mobj->scale : R_LerpFixed(mobj->old_scale, mobj->scale, frac);
|
|
||||||
out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
||||||
out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
||||||
|
|
||||||
|
if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs
|
||||||
|
{
|
||||||
|
out->scale = mobj->scale;
|
||||||
|
out->radius = mobj->radius;
|
||||||
|
out->height = mobj->height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
out->scale = R_LerpFixed(mobj->old_scale, mobj->scale, frac);
|
||||||
|
out->radius = FixedMul(mobj->radius, FixedDiv(out->scale, mobj->scale));
|
||||||
|
out->height = FixedMul(mobj->height, FixedDiv(out->scale, mobj->scale));
|
||||||
|
}
|
||||||
|
|
||||||
// Sprite offsets are not interpolated until we have a way to interpolate them explicitly in Lua.
|
// Sprite offsets are not interpolated until we have a way to interpolate them explicitly in Lua.
|
||||||
// It seems existing mods visually break more often than not if it is interpolated.
|
// It seems existing mods visually break more often than not if it is interpolated.
|
||||||
out->spritexoffset = mobj->spritexoffset;
|
out->spritexoffset = mobj->spritexoffset;
|
||||||
|
@ -340,6 +354,8 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
|
||||||
out->y = mobj->y;
|
out->y = mobj->y;
|
||||||
out->z = mobj->z;
|
out->z = mobj->z;
|
||||||
out->scale = FRACUNIT;
|
out->scale = FRACUNIT;
|
||||||
|
out->radius = mobj->radius;
|
||||||
|
out->height = mobj->height;
|
||||||
out->subsector = mobj->subsector;
|
out->subsector = mobj->subsector;
|
||||||
out->angle = mobj->angle;
|
out->angle = mobj->angle;
|
||||||
out->pitch = mobj->angle;
|
out->pitch = mobj->angle;
|
||||||
|
@ -356,6 +372,8 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
|
||||||
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
||||||
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
||||||
out->scale = FRACUNIT;
|
out->scale = FRACUNIT;
|
||||||
|
out->radius = mobj->radius;
|
||||||
|
out->height = mobj->height;
|
||||||
out->spritexscale = R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
out->spritexscale = R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
||||||
out->spriteyscale = R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
out->spriteyscale = R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
||||||
out->spritexoffset = R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
|
out->spritexoffset = R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
|
||||||
|
|
|
@ -63,6 +63,8 @@ typedef struct {
|
||||||
angle_t roll;
|
angle_t roll;
|
||||||
angle_t spriteroll;
|
angle_t spriteroll;
|
||||||
fixed_t scale;
|
fixed_t scale;
|
||||||
|
fixed_t radius;
|
||||||
|
fixed_t height;
|
||||||
fixed_t spritexscale;
|
fixed_t spritexscale;
|
||||||
fixed_t spriteyscale;
|
fixed_t spriteyscale;
|
||||||
fixed_t spritexoffset;
|
fixed_t spritexoffset;
|
||||||
|
|
|
@ -1193,7 +1193,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
|
||||||
R_InterpolateMobjState(thing, FRACUNIT, &interp);
|
R_InterpolateMobjState(thing, FRACUNIT, &interp);
|
||||||
}
|
}
|
||||||
|
|
||||||
halfHeight = interp.z + (thing->height >> 1);
|
halfHeight = interp.z + (interp.height >> 1);
|
||||||
floorz = P_GetFloorZ(thing, interp.subsector->sector, interp.x, interp.y, NULL);
|
floorz = P_GetFloorZ(thing, interp.subsector->sector, interp.x, interp.y, NULL);
|
||||||
ceilingz = P_GetCeilingZ(thing, interp.subsector->sector, interp.x, interp.y, NULL);
|
ceilingz = P_GetCeilingZ(thing, interp.subsector->sector, interp.x, interp.y, NULL);
|
||||||
|
|
||||||
|
@ -1257,8 +1257,8 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isflipped ? (ceilingz < groundz - (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2)))
|
if (isflipped ? (ceilingz < groundz - (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), interp.radius*3/2)))
|
||||||
: (floorz > groundz + (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), thing->radius*3/2))))
|
: (floorz > groundz + (!groundslope ? 0 : FixedMul(abs(groundslope->zdelta), interp.radius*3/2))))
|
||||||
{
|
{
|
||||||
groundz = isflipped ? ceilingz : floorz;
|
groundz = isflipped ? ceilingz : floorz;
|
||||||
groundslope = NULL;
|
groundslope = NULL;
|
||||||
|
@ -1301,9 +1301,9 @@ static void R_SkewShadowSprite(
|
||||||
//CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope);
|
//CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope);
|
||||||
|
|
||||||
if (viewz < groundz)
|
if (viewz < groundz)
|
||||||
*shadowyscale += FixedMul(FixedMul(thing->radius*2 / spriteheight, scalemul), zslope);
|
*shadowyscale += FixedMul(FixedMul(interp.radius*2 / spriteheight, scalemul), zslope);
|
||||||
else
|
else
|
||||||
*shadowyscale -= FixedMul(FixedMul(thing->radius*2 / spriteheight, scalemul), zslope);
|
*shadowyscale -= FixedMul(FixedMul(interp.radius*2 / spriteheight, scalemul), zslope);
|
||||||
|
|
||||||
*shadowyscale = abs((*shadowyscale));
|
*shadowyscale = abs((*shadowyscale));
|
||||||
*shadowskew = xslope;
|
*shadowskew = xslope;
|
||||||
|
@ -1354,20 +1354,18 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
floordiff = abs((isflipped ? thing->height : 0) + interp.z - groundz);
|
floordiff = abs((isflipped ? interp.height : 0) + interp.z - groundz);
|
||||||
|
|
||||||
trans = floordiff / (100*FRACUNIT) + 3;
|
trans = floordiff / (100*FRACUNIT) + 3;
|
||||||
if (trans >= 9) return;
|
if (trans >= 9) return;
|
||||||
|
|
||||||
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
|
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
|
||||||
if ((thing->scale != thing->old_scale) && (thing->scale >= FRACUNIT/1024)) // Interpolate shadows when scaling mobjs
|
|
||||||
scalemul = FixedMul(scalemul, FixedDiv(interp.scale, thing->scale));
|
|
||||||
|
|
||||||
patch = W_CachePatchName("DSHADOW", PU_SPRITE);
|
patch = W_CachePatchName("DSHADOW", PU_SPRITE);
|
||||||
xscale = FixedDiv(projection, tz);
|
xscale = FixedDiv(projection, tz);
|
||||||
yscale = FixedDiv(projectiony, tz);
|
yscale = FixedDiv(projectiony, tz);
|
||||||
shadowxscale = FixedMul(thing->radius*2, scalemul);
|
shadowxscale = FixedMul(interp.radius*2, scalemul);
|
||||||
shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(groundz - viewz), tz));
|
shadowyscale = FixedMul(FixedMul(interp.radius*2, scalemul), FixedDiv(abs(groundz - viewz), tz));
|
||||||
shadowyscale = min(shadowyscale, shadowxscale) / patch->height;
|
shadowyscale = min(shadowyscale, shadowxscale) / patch->height;
|
||||||
shadowxscale /= patch->width;
|
shadowxscale /= patch->width;
|
||||||
shadowskew = 0;
|
shadowskew = 0;
|
||||||
|
@ -1493,8 +1491,8 @@ static void R_ProjectBoundingBox(mobj_t *thing, vissprite_t *vis)
|
||||||
// 0--2
|
// 0--2
|
||||||
|
|
||||||
// start in the (0) corner
|
// start in the (0) corner
|
||||||
gx = interp.x - thing->radius - viewx;
|
gx = interp.x - interp.radius - viewx;
|
||||||
gy = interp.y - thing->radius - viewy;
|
gy = interp.y - interp.radius - viewy;
|
||||||
|
|
||||||
tz = FixedMul(gx, viewcos) + FixedMul(gy, viewsin);
|
tz = FixedMul(gx, viewcos) + FixedMul(gy, viewsin);
|
||||||
|
|
||||||
|
@ -1516,14 +1514,14 @@ static void R_ProjectBoundingBox(mobj_t *thing, vissprite_t *vis)
|
||||||
box = R_NewVisSprite();
|
box = R_NewVisSprite();
|
||||||
box->mobj = thing;
|
box->mobj = thing;
|
||||||
box->mobjflags = thing->flags;
|
box->mobjflags = thing->flags;
|
||||||
box->thingheight = thing->height;
|
box->thingheight = interp.height;
|
||||||
box->cut = SC_BBOX;
|
box->cut = SC_BBOX;
|
||||||
|
|
||||||
box->gx = tx;
|
box->gx = tx;
|
||||||
box->gy = tz;
|
box->gy = tz;
|
||||||
|
|
||||||
box->scale = 2 * FixedMul(thing->radius, viewsin);
|
box->scale = 2 * FixedMul(interp.radius, viewsin);
|
||||||
box->xscale = 2 * FixedMul(thing->radius, viewcos);
|
box->xscale = 2 * FixedMul(interp.radius, viewcos);
|
||||||
|
|
||||||
box->pz = interp.z;
|
box->pz = interp.z;
|
||||||
box->pzt = box->pz + box->thingheight;
|
box->pzt = box->pz + box->thingheight;
|
||||||
|
@ -1572,6 +1570,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
fixed_t tr_x, tr_y;
|
fixed_t tr_x, tr_y;
|
||||||
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 radius, height; // For drop shadows
|
||||||
fixed_t sortscale, sortsplat = 0;
|
fixed_t sortscale, sortsplat = 0;
|
||||||
fixed_t linkscale = 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;
|
||||||
|
@ -1647,6 +1646,8 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
}
|
}
|
||||||
|
|
||||||
this_scale = interp.scale;
|
this_scale = interp.scale;
|
||||||
|
radius = interp.radius; // For drop shadows
|
||||||
|
height = interp.height; // Ditto
|
||||||
|
|
||||||
// transform the origin point
|
// transform the origin point
|
||||||
tr_x = interp.x - viewx;
|
tr_x = interp.x - viewx;
|
||||||
|
@ -1986,6 +1987,8 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
{
|
{
|
||||||
R_InterpolateMobjState(thing, FRACUNIT, &tracer_interp);
|
R_InterpolateMobjState(thing, FRACUNIT, &tracer_interp);
|
||||||
}
|
}
|
||||||
|
radius = tracer_interp.radius; // For drop shadows
|
||||||
|
height = tracer_interp.height; // Ditto
|
||||||
|
|
||||||
tr_x = (tracer_interp.x + sort_x) - viewx;
|
tr_x = (tracer_interp.x + sort_x) - viewx;
|
||||||
tr_y = (tracer_interp.y + sort_y) - viewy;
|
tr_y = (tracer_interp.y + sort_y) - viewy;
|
||||||
|
@ -2077,7 +2080,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
if (abs(groundz-viewz)/tz > 4)
|
if (abs(groundz-viewz)/tz > 4)
|
||||||
return; // Prevent stretchy shadows and possible crashes
|
return; // Prevent stretchy shadows and possible crashes
|
||||||
|
|
||||||
floordiff = abs((isflipped ? caster->height : 0) + casterinterp.z - groundz);
|
floordiff = abs((isflipped ? casterinterp.height : 0) + casterinterp.z - groundz);
|
||||||
trans += ((floordiff / (100*FRACUNIT)) + 3);
|
trans += ((floordiff / (100*FRACUNIT)) + 3);
|
||||||
shadowscale = FixedMul(FRACUNIT - floordiff/640, casterinterp.scale);
|
shadowscale = FixedMul(FRACUNIT - floordiff/640, casterinterp.scale);
|
||||||
}
|
}
|
||||||
|
@ -2092,8 +2095,8 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
if (shadowdraw)
|
if (shadowdraw)
|
||||||
{
|
{
|
||||||
spritexscale = FixedMul(thing->radius * 2, FixedMul(shadowscale, spritexscale));
|
spritexscale = FixedMul(radius * 2, FixedMul(shadowscale, spritexscale));
|
||||||
spriteyscale = FixedMul(thing->radius * 2, FixedMul(shadowscale, spriteyscale));
|
spriteyscale = FixedMul(radius * 2, FixedMul(shadowscale, spriteyscale));
|
||||||
spriteyscale = FixedMul(spriteyscale, FixedDiv(abs(groundz - viewz), tz));
|
spriteyscale = FixedMul(spriteyscale, FixedDiv(abs(groundz - viewz), tz));
|
||||||
spriteyscale = min(spriteyscale, spritexscale) / patch->height;
|
spriteyscale = min(spriteyscale, spritexscale) / patch->height;
|
||||||
spritexscale /= patch->width;
|
spritexscale /= patch->width;
|
||||||
|
@ -2108,7 +2111,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
{
|
{
|
||||||
R_SkewShadowSprite(thing, thing->standingslope, groundz, patch->height, shadowscale, &spriteyscale, &sheartan);
|
R_SkewShadowSprite(thing, thing->standingslope, groundz, patch->height, shadowscale, &spriteyscale, &sheartan);
|
||||||
|
|
||||||
gzt = (isflipped ? (interp.z + thing->height) : interp.z) + patch->height * spriteyscale / 2;
|
gzt = (isflipped ? (interp.z + height) : interp.z) + patch->height * spriteyscale / 2;
|
||||||
gz = gzt - patch->height * spriteyscale;
|
gz = gzt - patch->height * spriteyscale;
|
||||||
|
|
||||||
cut |= SC_SHEAR;
|
cut |= SC_SHEAR;
|
||||||
|
@ -2123,11 +2126,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
// When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned.
|
// When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned.
|
||||||
// sprite height - sprite topoffset is the proper inverse of the vertical offset, of course.
|
// sprite height - sprite topoffset is the proper inverse of the vertical offset, of course.
|
||||||
// remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes!
|
// remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes!
|
||||||
|
gz = interp.z + interp.height - FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale));
|
||||||
if (oldthing->scale != oldthing->old_scale) // Interpolate heights in reverse gravity when scaling mobjs
|
|
||||||
gz = interp.z + FixedMul(oldthing->height, FixedDiv(interp.scale, oldthing->scale)) - FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale));
|
|
||||||
else
|
|
||||||
gz = interp.z + oldthing->height - FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale));
|
|
||||||
gzt = gz + FixedMul(spr_height, FixedMul(spriteyscale, this_scale));
|
gzt = gz + FixedMul(spr_height, FixedMul(spriteyscale, this_scale));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2206,7 +2205,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
vis->gy = interp.y;
|
vis->gy = interp.y;
|
||||||
vis->gz = gz;
|
vis->gz = gz;
|
||||||
vis->gzt = gzt;
|
vis->gzt = gzt;
|
||||||
vis->thingheight = thing->height;
|
vis->thingheight = height;
|
||||||
vis->pz = interp.z;
|
vis->pz = interp.z;
|
||||||
vis->pzt = vis->pz + vis->thingheight;
|
vis->pzt = vis->pz + vis->thingheight;
|
||||||
vis->texturemid = FixedDiv(gzt - viewz, spriteyscale);
|
vis->texturemid = FixedDiv(gzt - viewz, spriteyscale);
|
||||||
|
|
Loading…
Reference in a new issue