Add SideScroll interpolator

This commit is contained in:
Eidolon 2022-04-12 21:35:52 -05:00
parent ba110852a7
commit 330b34ee6b
3 changed files with 29 additions and 0 deletions

View file

@ -7413,6 +7413,7 @@ static void Add_Scroller(INT32 type, fixed_t dx, fixed_t dy, INT32 control, INT3
switch (type)
{
case sc_side:
R_CreateInterpolator_SideScroll(&s->thinker, &sides[affectee]);
break;
case sc_floor:
R_CreateInterpolator_SectorScroll(&s->thinker, &sectors[affectee], false);

View file

@ -276,6 +276,14 @@ void R_CreateInterpolator_SectorScroll(thinker_t *thinker, sector_t *sector, boo
}
}
void R_CreateInterpolator_SideScroll(thinker_t *thinker, side_t *side)
{
levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_SideScroll, thinker);
interp->sidescroll.side = side;
interp->sidescroll.oldtextureoffset = interp->sidescroll.baktextureoffset = side->textureoffset;
interp->sidescroll.oldrowoffset = interp->sidescroll.bakrowoffset = side->rowoffset;
}
void R_InitializeLevelInterpolators(void)
{
levelinterpolators_len = 0;
@ -297,6 +305,12 @@ static void UpdateLevelInterpolatorState(levelinterpolator_t *interp)
interp->sectorscroll.oldyoffs = interp->sectorscroll.bakyoffs;
interp->sectorscroll.bakyoffs = interp->sectorscroll.ceiling ? interp->sectorscroll.sector->ceiling_yoffs : interp->sectorscroll.sector->floor_yoffs;
break;
case LVLINTERP_SideScroll:
interp->sidescroll.oldtextureoffset = interp->sidescroll.baktextureoffset;
interp->sidescroll.baktextureoffset = interp->sidescroll.side->textureoffset;
interp->sidescroll.oldrowoffset = interp->sidescroll.bakrowoffset;
interp->sidescroll.bakrowoffset = interp->sidescroll.side->rowoffset;
break;
}
}
@ -362,6 +376,10 @@ void R_ApplyLevelInterpolators(fixed_t frac)
interp->sectorscroll.sector->floor_yoffs = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac);
}
break;
case LVLINTERP_SideScroll:
interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac);
interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac);
break;
}
}
}
@ -398,6 +416,10 @@ void R_RestoreLevelInterpolators(void)
interp->sectorscroll.sector->floor_yoffs = interp->sectorscroll.bakyoffs;
}
break;
case LVLINTERP_SideScroll:
interp->sidescroll.side->textureoffset = interp->sidescroll.baktextureoffset;
interp->sidescroll.side->rowoffset = interp->sidescroll.bakrowoffset;
break;
}
}
}

View file

@ -57,6 +57,7 @@ typedef struct {
typedef enum {
LVLINTERP_SectorPlane,
LVLINTERP_SectorScroll,
LVLINTERP_SideScroll,
} levelinterpolator_type_e;
// Tagged union of a level interpolator
@ -75,6 +76,10 @@ typedef struct levelinterpolator_s {
fixed_t oldxoffs, oldyoffs, bakxoffs, bakyoffs;
boolean ceiling;
} sectorscroll;
struct {
side_t *side;
fixed_t oldtextureoffset, oldrowoffset, baktextureoffset, bakrowoffset;
} sidescroll;
};
} levelinterpolator_t;
@ -93,6 +98,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst
void R_CreateInterpolator_SectorPlane(thinker_t *thinker, sector_t *sector, boolean ceiling);
void R_CreateInterpolator_SectorScroll(thinker_t *thinker, sector_t *sector, boolean ceiling);
void R_CreateInterpolator_SideScroll(thinker_t *thinker, side_t *side);
// Initialize level interpolators after a level change
void R_InitializeLevelInterpolators(void);