mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-24 19:52:08 +00:00
Interpolate spritescale/offset x/y
This commit is contained in:
parent
8f43b5afd0
commit
1259f1be40
6 changed files with 56 additions and 18 deletions
|
@ -5084,9 +5084,6 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
|||
if (!thing)
|
||||
return;
|
||||
|
||||
if (thing->spritexscale < 1 || thing->spriteyscale < 1)
|
||||
return;
|
||||
|
||||
INT32 blendmode;
|
||||
if (thing->frame & FF_BLENDMASK)
|
||||
blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1;
|
||||
|
@ -5112,9 +5109,12 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
|||
R_InterpolateMobjState(thing, FRACUNIT, &interp);
|
||||
}
|
||||
|
||||
if (interp.spritexscale < 1 || interp.spriteyscale < 1)
|
||||
return;
|
||||
|
||||
this_scale = FIXED_TO_FLOAT(interp.scale);
|
||||
spritexscale = FIXED_TO_FLOAT(thing->spritexscale);
|
||||
spriteyscale = FIXED_TO_FLOAT(thing->spriteyscale);
|
||||
spritexscale = FIXED_TO_FLOAT(interp.spritexscale);
|
||||
spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale);
|
||||
|
||||
// transform the origin point
|
||||
tr_x = FIXED_TO_FLOAT(interp.x) - gl_viewx;
|
||||
|
@ -5258,8 +5258,8 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
|||
|
||||
if (thing->renderflags & RF_ABSOLUTEOFFSETS)
|
||||
{
|
||||
spr_offset = thing->spritexoffset;
|
||||
spr_topoffset = thing->spriteyoffset;
|
||||
spr_offset = interp.spritexoffset;
|
||||
spr_topoffset = interp.spriteyoffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5268,8 +5268,8 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
|||
if ((thing->renderflags & RF_FLIPOFFSETS) && flip)
|
||||
flipoffset = -1;
|
||||
|
||||
spr_offset += thing->spritexoffset * flipoffset;
|
||||
spr_topoffset += thing->spriteyoffset * flipoffset;
|
||||
spr_offset += interp.spritexoffset * flipoffset;
|
||||
spr_topoffset += interp.spriteyoffset * flipoffset;
|
||||
}
|
||||
|
||||
if (papersprite)
|
||||
|
|
|
@ -10593,8 +10593,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
|||
// Tells MobjCheckWater that the water height was not set.
|
||||
mobj->watertop = INT32_MAX;
|
||||
|
||||
mobj->resetinterp = true;
|
||||
|
||||
if (z == ONFLOORZ)
|
||||
{
|
||||
mobj->z = mobj->floorz;
|
||||
|
@ -14032,9 +14030,14 @@ mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zo
|
|||
newmobj->old_angle2 = mobj->old_angle2;
|
||||
newmobj->old_angle = mobj->old_angle;
|
||||
}
|
||||
newmobj->resetinterp = true;
|
||||
|
||||
newmobj->old_scale2 = mobj->old_scale2;
|
||||
newmobj->old_scale = mobj->old_scale;
|
||||
newmobj->old_spritexscale = mobj->old_spritexscale;
|
||||
newmobj->old_spriteyscale = mobj->old_spriteyscale;
|
||||
newmobj->old_spritexoffset = mobj->old_spritexoffset;
|
||||
newmobj->old_spriteyoffset = mobj->old_spriteyoffset;
|
||||
|
||||
return newmobj;
|
||||
}
|
||||
|
|
|
@ -302,6 +302,8 @@ typedef struct mobj_s
|
|||
INT32 blendmode; // blend mode
|
||||
fixed_t spritexscale, spriteyscale;
|
||||
fixed_t spritexoffset, spriteyoffset;
|
||||
fixed_t old_spritexscale, old_spriteyscale;
|
||||
fixed_t old_spritexoffset, old_spriteyoffset;
|
||||
struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by
|
||||
|
||||
struct msecnode_s *touching_sectorlist; // a linked list of sectors where this object appears
|
||||
|
@ -436,6 +438,8 @@ typedef struct precipmobj_s
|
|||
INT32 blendmode; // blend mode
|
||||
fixed_t spritexscale, spriteyscale;
|
||||
fixed_t spritexoffset, spriteyoffset;
|
||||
fixed_t old_spritexscale, old_spriteyscale;
|
||||
fixed_t old_spritexoffset, old_spriteyoffset;
|
||||
struct pslope_s *floorspriteslope; // The slope that the floorsprite is rotated by
|
||||
|
||||
struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears
|
||||
|
|
29
src/r_fps.c
29
src/r_fps.c
|
@ -271,13 +271,21 @@ void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
|||
out->scale = mobj->scale;
|
||||
out->subsector = mobj->subsector;
|
||||
out->angle = mobj->player ? mobj->player->drawangle : mobj->angle;
|
||||
out->spritexscale = mobj->spritexscale;
|
||||
out->spriteyscale = mobj->spriteyscale;
|
||||
out->spritexoffset = mobj->spritexoffset;
|
||||
out->spriteyoffset = mobj->spriteyoffset;
|
||||
return;
|
||||
}
|
||||
|
||||
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
|
||||
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
||||
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
||||
out->scale = R_LerpFixed(mobj->old_scale, mobj->scale, 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->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
||||
out->spritexoffset = mobj->resetinterp ? mobj->spritexoffset : R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
|
||||
out->spriteyoffset = mobj->resetinterp ? mobj->spriteyoffset : R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac);
|
||||
|
||||
out->subsector = R_PointInSubsector(out->x, out->y);
|
||||
|
||||
|
@ -298,14 +306,24 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
|
|||
out->x = mobj->x;
|
||||
out->y = mobj->y;
|
||||
out->z = mobj->z;
|
||||
out->scale = FRACUNIT;
|
||||
out->subsector = mobj->subsector;
|
||||
out->angle = mobj->angle;
|
||||
out->spritexscale = mobj->spritexscale;
|
||||
out->spriteyscale = mobj->spriteyscale;
|
||||
out->spritexoffset = mobj->spritexoffset;
|
||||
out->spriteyoffset = mobj->spriteyoffset;
|
||||
return;
|
||||
}
|
||||
|
||||
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
|
||||
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
||||
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
||||
out->scale = FRACUNIT;
|
||||
out->spritexscale = R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
||||
out->spriteyscale = R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
||||
out->spritexoffset = R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
|
||||
out->spriteyoffset = R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac);
|
||||
|
||||
out->subsector = R_PointInSubsector(out->x, out->y);
|
||||
|
||||
|
@ -672,6 +690,7 @@ void R_AddMobjInterpolator(mobj_t *mobj)
|
|||
interpolated_mobjs_len += 1;
|
||||
|
||||
R_ResetMobjInterpolationState(mobj);
|
||||
mobj->resetinterp = true;
|
||||
}
|
||||
|
||||
void R_RemoveMobjInterpolator(mobj_t *mobj)
|
||||
|
@ -734,6 +753,10 @@ void R_ResetMobjInterpolationState(mobj_t *mobj)
|
|||
mobj->old_pitch = mobj->pitch;
|
||||
mobj->old_roll = mobj->roll;
|
||||
mobj->old_scale = mobj->scale;
|
||||
mobj->old_spritexscale = mobj->spritexscale;
|
||||
mobj->old_spriteyscale = mobj->spriteyscale;
|
||||
mobj->old_spritexoffset = mobj->spritexoffset;
|
||||
mobj->old_spriteyoffset = mobj->spriteyoffset;
|
||||
|
||||
if (mobj->player)
|
||||
{
|
||||
|
@ -761,4 +784,8 @@ void R_ResetPrecipitationMobjInterpolationState(precipmobj_t *mobj)
|
|||
mobj->old_y = mobj->y;
|
||||
mobj->old_z = mobj->z;
|
||||
mobj->old_angle = mobj->angle;
|
||||
mobj->old_spritexscale = mobj->spritexscale;
|
||||
mobj->old_spriteyscale = mobj->spriteyscale;
|
||||
mobj->old_spritexoffset = mobj->spritexoffset;
|
||||
mobj->old_spriteyoffset = mobj->spriteyoffset;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,10 @@ typedef struct {
|
|||
subsector_t *subsector;
|
||||
angle_t angle;
|
||||
fixed_t scale;
|
||||
fixed_t spritexscale;
|
||||
fixed_t spriteyscale;
|
||||
fixed_t spritexoffset;
|
||||
fixed_t spriteyoffset;
|
||||
} interpmobjstate_t;
|
||||
|
||||
// Level interpolators
|
||||
|
|
|
@ -1671,15 +1671,15 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
flip = !flip != !hflip;
|
||||
|
||||
// calculate edges of the shape
|
||||
spritexscale = thing->spritexscale;
|
||||
spriteyscale = thing->spriteyscale;
|
||||
spritexscale = interp.spritexscale;
|
||||
spriteyscale = interp.spriteyscale;
|
||||
if (spritexscale < 1 || spriteyscale < 1)
|
||||
return;
|
||||
|
||||
if (thing->renderflags & RF_ABSOLUTEOFFSETS)
|
||||
{
|
||||
spr_offset = thing->spritexoffset;
|
||||
spr_topoffset = thing->spriteyoffset;
|
||||
spr_offset = interp.spritexoffset;
|
||||
spr_topoffset = interp.spriteyoffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1688,8 +1688,8 @@ static void R_ProjectSprite(mobj_t *thing)
|
|||
if ((thing->renderflags & RF_FLIPOFFSETS) && flip)
|
||||
flipoffset = -1;
|
||||
|
||||
spr_offset += thing->spritexoffset * flipoffset;
|
||||
spr_topoffset += thing->spriteyoffset * flipoffset;
|
||||
spr_offset += interp.spritexoffset * flipoffset;
|
||||
spr_topoffset += interp.spriteyoffset * flipoffset;
|
||||
}
|
||||
|
||||
if (flip)
|
||||
|
|
Loading…
Reference in a new issue