Apply interp to models, apply sprite world offsets properly

This commit is contained in:
Sally Coolatta 2021-11-29 08:46:56 -05:00
parent c43f8da5e6
commit 5fea80c61b
3 changed files with 84 additions and 32 deletions

View file

@ -3624,10 +3624,6 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v
static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
{ {
fixed_t thingxpos = thing->x + thing->sprxoff;
fixed_t thingypos = thing->y + thing->spryoff;
fixed_t thingzpos = thing->z + thing->sprzoff;
patch_t *gpatch; patch_t *gpatch;
FOutVector shadowVerts[4]; FOutVector shadowVerts[4];
FSurfaceInfo sSurf; FSurfaceInfo sSurf;
@ -3644,7 +3640,19 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
fixed_t slopez; fixed_t slopez;
pslope_t *groundslope; pslope_t *groundslope;
// hitlag vibrating fixed_t interpx = thing->x;
fixed_t interpy = thing->y;
fixed_t interpz = thing->z;
// do interpolation
if (cv_frameinterpolation.value == 1 && !paused)
{
interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x);
interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y);
interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z);
}
// hitlag vibrating (todo: interp somehow?)
if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG))
{ {
fixed_t mul = thing->hitlag * (FRACUNIT / 10); fixed_t mul = thing->hitlag * (FRACUNIT / 10);
@ -3654,14 +3662,19 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
mul = -mul; mul = -mul;
} }
thingxpos += FixedMul(thing->momx, mul); interpx += FixedMul(thing->momx, mul);
thingypos += FixedMul(thing->momy, mul); interpy += FixedMul(thing->momy, mul);
thingzpos += FixedMul(thing->momz, mul); interpz += FixedMul(thing->momz, mul);
} }
// sprite offset
interpx += thing->sprxoff;
interpy += thing->spryoff;
interpz += thing->sprzoff;
groundz = R_GetShadowZ(thing, &groundslope); groundz = R_GetShadowZ(thing, &groundslope);
floordiff = abs((flip < 0 ? thing->height : 0) + thingzpos - groundz); floordiff = abs((flip < 0 ? thing->height : 0) + interpz - groundz);
alpha = floordiff / (4*FRACUNIT) + 75; alpha = floordiff / (4*FRACUNIT) + 75;
if (alpha >= 255) return; if (alpha >= 255) return;
@ -3675,8 +3688,8 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height); scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height);
fscale = FIXED_TO_FLOAT(scalemul); fscale = FIXED_TO_FLOAT(scalemul);
fx = FIXED_TO_FLOAT(thingxpos); fx = FIXED_TO_FLOAT(interpx);
fy = FIXED_TO_FLOAT(thingypos); fy = FIXED_TO_FLOAT(interpy);
// 3--2 // 3--2
// | /| // | /|
@ -5067,9 +5080,9 @@ static void HWR_ProjectSprite(mobj_t *thing)
dispoffset = thing->info->dispoffset; dispoffset = thing->info->dispoffset;
interpx = thing->x + thing->sprxoff; interpx = thing->x;
interpy = thing->y + thing->spryoff; interpy = thing->y;
interpz = thing->z + thing->sprzoff; interpz = thing->z;
interpangle = mobjangle; interpangle = mobjangle;
if (cv_frameinterpolation.value == 1 && !paused) if (cv_frameinterpolation.value == 1 && !paused)
@ -5095,6 +5108,11 @@ static void HWR_ProjectSprite(mobj_t *thing)
interpz += FixedMul(thing->momz, mul); interpz += FixedMul(thing->momz, mul);
} }
// sprite offset
interpx += thing->sprxoff;
interpy += thing->spryoff;
interpz += thing->sprzoff;
this_scale = FIXED_TO_FLOAT(thing->scale); this_scale = FIXED_TO_FLOAT(thing->scale);
spritexscale = FIXED_TO_FLOAT(thing->spritexscale); spritexscale = FIXED_TO_FLOAT(thing->spritexscale);
spriteyscale = FIXED_TO_FLOAT(thing->spriteyscale); spriteyscale = FIXED_TO_FLOAT(thing->spriteyscale);

View file

@ -1355,10 +1355,6 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
// Look at HWR_ProjectSprite for more // Look at HWR_ProjectSprite for more
{ {
fixed_t thingxpos = spr->mobj->x + spr->mobj->sprxoff;
fixed_t thingypos = spr->mobj->y + spr->mobj->spryoff;
fixed_t thingzpos = spr->mobj->z + spr->mobj->sprzoff;
patch_t *gpatch, *blendgpatch; patch_t *gpatch, *blendgpatch;
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
INT32 durs = spr->mobj->state->tics; INT32 durs = spr->mobj->state->tics;
@ -1371,6 +1367,18 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
INT32 mod; INT32 mod;
float finalscale; float finalscale;
fixed_t interpx = spr->mobj->x;
fixed_t interpy = spr->mobj->y;
fixed_t interpz = spr->mobj->z;
// do interpolation
if (cv_frameinterpolation.value == 1 && !paused)
{
interpx = spr->mobj->old_x + FixedMul(rendertimefrac, spr->mobj->x - spr->mobj->old_x);
interpy = spr->mobj->old_y + FixedMul(rendertimefrac, spr->mobj->y - spr->mobj->old_y);
interpz = spr->mobj->old_z + FixedMul(rendertimefrac, spr->mobj->z - spr->mobj->old_z);
}
// hitlag vibrating // hitlag vibrating
if (spr->mobj->hitlag > 0 && (spr->mobj->eflags & MFE_DAMAGEHITLAG)) if (spr->mobj->hitlag > 0 && (spr->mobj->eflags & MFE_DAMAGEHITLAG))
{ {
@ -1381,11 +1389,16 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
mul = -mul; mul = -mul;
} }
thingxpos += FixedMul(spr->mobj->momx, mul); interpx += FixedMul(spr->mobj->momx, mul);
thingypos += FixedMul(spr->mobj->momy, mul); interpy += FixedMul(spr->mobj->momy, mul);
thingzpos += FixedMul(spr->mobj->momz, mul); interpy += FixedMul(spr->mobj->momz, mul);
} }
// sprite offset
interpx += spr->mobj->sprxoff;
interpy += spr->mobj->spryoff;
interpz += spr->mobj->sprzoff;
// Apparently people don't like jump frames like that, so back it goes // Apparently people don't like jump frames like that, so back it goes
//if (tics > durs) //if (tics > durs)
//durs = tics; //durs = tics;
@ -1605,13 +1618,13 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
#endif #endif
//Hurdler: it seems there is still a small problem with mobj angle //Hurdler: it seems there is still a small problem with mobj angle
p.x = FIXED_TO_FLOAT(thingxpos); p.x = FIXED_TO_FLOAT(interpx);
p.y = FIXED_TO_FLOAT(thingypos) + md2->offset; p.y = FIXED_TO_FLOAT(interpy) + md2->offset;
if (flip) if (flip)
p.z = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height); p.z = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height);
else else
p.z = FIXED_TO_FLOAT(thingzpos); p.z = FIXED_TO_FLOAT(interpz);
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
sprdef = &((skin_t *)spr->mobj->skin)->sprites[spr->mobj->sprite2]; sprdef = &((skin_t *)spr->mobj->skin)->sprites[spr->mobj->sprite2];
@ -1631,7 +1644,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
} }
else else
{ {
const fixed_t anglef = AngleFixed((R_PointToAngle(thingxpos, thingypos))-ANGLE_180); const fixed_t anglef = AngleFixed((R_PointToAngle(interpx, interpy))-ANGLE_180);
p.angley = FIXED_TO_FLOAT(anglef); p.angley = FIXED_TO_FLOAT(anglef);
} }

View file

@ -1363,10 +1363,6 @@ static void R_ProjectSprite(mobj_t *thing)
{ {
mobj_t *oldthing = thing; mobj_t *oldthing = thing;
//const fixed_t oldthingxpos = oldthing->x + oldthing->sprxoff;
//const fixed_t oldthingypos = oldthing->y + oldthing->spryoff;
//const fixed_t oldthingzpos = oldthing->z + oldthing->sprzoff;
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!!!
@ -1432,9 +1428,9 @@ static void R_ProjectSprite(mobj_t *thing)
#endif #endif
// uncapped/interpolation // uncapped/interpolation
fixed_t interpx = thing->x + thing->sprxoff; fixed_t interpx = thing->x;
fixed_t interpy = thing->y + thing->spryoff; fixed_t interpy = thing->y;
fixed_t interpz = thing->z + thing->sprzoff; fixed_t interpz = thing->z;
angle_t interpangle = thing->angle; angle_t interpangle = thing->angle;
// use player drawangle if player // use player drawangle if player
@ -1471,6 +1467,11 @@ static void R_ProjectSprite(mobj_t *thing)
interpz += FixedMul(thing->momz, mul); interpz += FixedMul(thing->momz, mul);
} }
// sprite offset
interpx += thing->sprxoff;
interpy += thing->spryoff;
interpz += thing->sprzoff;
// transform the origin point // transform the origin point
tr_x = interpx - viewx; tr_x = interpx - viewx;
tr_y = interpy - viewy; tr_y = interpy - viewy;
@ -1782,6 +1783,26 @@ static void R_ProjectSprite(mobj_t *thing)
interpy = thing->old_y + FixedMul(thing->y - thing->old_y, rendertimefrac); interpy = thing->old_y + FixedMul(thing->y - thing->old_y, rendertimefrac);
} }
// hitlag vibrating (todo: interp somehow?)
if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG))
{
fixed_t mul = thing->hitlag * (FRACUNIT / 10);
if (leveltime & 1)
{
mul = -mul;
}
interpx += FixedMul(thing->momx, mul);
interpy += FixedMul(thing->momy, mul);
interpz += FixedMul(thing->momz, mul);
}
// sprite offset
interpx += thing->sprxoff;
interpy += thing->spryoff;
interpz += thing->sprzoff;
if (! R_ThingVisible(thing)) if (! R_ThingVisible(thing))
return; return;