mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 03:12:00 -04:00
redo interpolation of scrollers animation (#1219)
* add old* fields * remove R_InterpolateTextureOffets() function, move code to r_bsp.c
This commit is contained in:
parent
51ccc03461
commit
54eb621036
@ -2568,8 +2568,6 @@ void P_UnArchiveSpecials (void)
|
||||
{
|
||||
byte tclass;
|
||||
|
||||
P_FreeScrollers();
|
||||
|
||||
// read in saved thinkers
|
||||
while ((tclass = saveg_read8()) != tc_endspecials) // killough 2/14/98
|
||||
switch (tclass)
|
||||
@ -2689,8 +2687,6 @@ void P_UnArchiveSpecials (void)
|
||||
saveg_read_scroll_t(scroll);
|
||||
scroll->thinker.function.p1 = (actionf_p1)T_Scroll;
|
||||
P_AddThinker(&scroll->thinker);
|
||||
if (scroll->type >= sc_side && scroll->type <= sc_ceiling)
|
||||
P_AddScroller(scroll);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -304,8 +304,12 @@ void P_LoadSectors (int lump)
|
||||
// killough 3/7/98:
|
||||
ss->floor_xoffs = 0;
|
||||
ss->floor_yoffs = 0; // floor and ceiling flats offsets
|
||||
ss->old_floor_xoffs = ss->base_floor_xoffs = 0;
|
||||
ss->old_floor_yoffs = ss->base_floor_yoffs = 0;
|
||||
ss->ceiling_xoffs = 0;
|
||||
ss->ceiling_yoffs = 0;
|
||||
ss->old_ceiling_xoffs = ss->base_ceiling_xoffs = 0;
|
||||
ss->old_ceiling_yoffs = ss->base_ceiling_yoffs = 0;
|
||||
ss->heightsec = -1; // sector used to get floor and ceiling height
|
||||
ss->floorlightsec = -1; // sector used to get floor lighting
|
||||
// killough 3/7/98: end changes
|
||||
@ -329,6 +333,7 @@ void P_LoadSectors (int lump)
|
||||
// [FG] inhibit sector interpolation during the 0th gametic
|
||||
ss->oldceilgametic = -1;
|
||||
ss->oldfloorgametic = -1;
|
||||
ss->oldscrollgametic = -1;
|
||||
}
|
||||
|
||||
Z_Free (data);
|
||||
@ -579,8 +584,11 @@ void P_LoadSideDefs2(int lump)
|
||||
sd->textureoffset = SHORT(msd->textureoffset)<<FRACBITS;
|
||||
sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;
|
||||
// [crispy] smooth texture scrolling
|
||||
sd->oldtextureoffset = sd->textureoffset;
|
||||
sd->oldrowoffset = sd->rowoffset;
|
||||
sd->basetextureoffset = sd->textureoffset;
|
||||
sd->baserowoffset = sd->rowoffset;
|
||||
sd->oldgametic = -1;
|
||||
|
||||
// killough 4/4/98: allow sidedef texture names to be overloaded
|
||||
// killough 4/11/98: refined to allow colormaps to work as wall
|
||||
|
108
src/p_spec.c
108
src/p_spec.c
@ -2642,6 +2642,12 @@ void T_Scroll(scroll_t *s)
|
||||
|
||||
case sc_side: // killough 3/7/98: Scroll wall texture
|
||||
side = sides + s->affectee;
|
||||
if (side->oldgametic != gametic)
|
||||
{
|
||||
side->oldtextureoffset = side->basetextureoffset;
|
||||
side->oldrowoffset = side->baserowoffset;
|
||||
side->oldgametic = gametic;
|
||||
}
|
||||
side->basetextureoffset += dx;
|
||||
side->baserowoffset += dy;
|
||||
side->textureoffset = side->basetextureoffset;
|
||||
@ -2650,6 +2656,12 @@ void T_Scroll(scroll_t *s)
|
||||
|
||||
case sc_floor: // killough 3/7/98: Scroll floor texture
|
||||
sec = sectors + s->affectee;
|
||||
if (sec->oldscrollgametic != gametic)
|
||||
{
|
||||
sec->old_floor_xoffs = sec->base_floor_xoffs;
|
||||
sec->old_floor_yoffs = sec->base_floor_yoffs;
|
||||
sec->oldscrollgametic = gametic;
|
||||
}
|
||||
sec->base_floor_xoffs += dx;
|
||||
sec->base_floor_yoffs += dy;
|
||||
sec->floor_xoffs = sec->base_floor_xoffs;
|
||||
@ -2658,6 +2670,12 @@ void T_Scroll(scroll_t *s)
|
||||
|
||||
case sc_ceiling: // killough 3/7/98: Scroll ceiling texture
|
||||
sec = sectors + s->affectee;
|
||||
if (sec->oldscrollgametic != gametic)
|
||||
{
|
||||
sec->old_ceiling_xoffs = sec->base_ceiling_xoffs;
|
||||
sec->old_ceiling_yoffs = sec->base_ceiling_yoffs;
|
||||
sec->oldscrollgametic = gametic;
|
||||
}
|
||||
sec->base_ceiling_xoffs += dx;
|
||||
sec->base_ceiling_yoffs += dy;
|
||||
sec->ceiling_xoffs = sec->base_ceiling_xoffs;
|
||||
@ -2695,91 +2713,6 @@ void T_Scroll(scroll_t *s)
|
||||
}
|
||||
}
|
||||
|
||||
// [crispy] smooth texture scrolling
|
||||
|
||||
static int maxscrollers, numscrollers;
|
||||
static scroll_t **scrollers;
|
||||
|
||||
void P_AddScroller (scroll_t *s)
|
||||
{
|
||||
if (numscrollers == maxscrollers)
|
||||
{
|
||||
maxscrollers = maxscrollers ? 2 * maxscrollers : 32;
|
||||
scrollers = I_Realloc(scrollers, maxscrollers * sizeof(*scrollers));
|
||||
}
|
||||
scrollers[numscrollers++] = s;
|
||||
}
|
||||
|
||||
void P_FreeScrollers (void)
|
||||
{
|
||||
maxscrollers = 0;
|
||||
numscrollers = 0;
|
||||
if (scrollers)
|
||||
free(scrollers);
|
||||
scrollers = NULL;
|
||||
}
|
||||
|
||||
void R_InterpolateTextureOffsets (void)
|
||||
{
|
||||
if (uncapped && leveltime > oldleveltime && !frozen_mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numscrollers; i++)
|
||||
{
|
||||
scroll_t *s = scrollers[i];
|
||||
int dx, dy;
|
||||
|
||||
if (s->accel)
|
||||
{
|
||||
dx = s->vdx;
|
||||
dy = s->vdy;
|
||||
}
|
||||
else
|
||||
{
|
||||
dx = s->dx;
|
||||
dy = s->dy;
|
||||
|
||||
if (s->control != -1)
|
||||
{ // compute scroll amounts based on a sector's height changes
|
||||
fixed_t height = sectors[s->control].floorheight +
|
||||
sectors[s->control].ceilingheight;
|
||||
fixed_t delta = height - s->last_height;
|
||||
dx = FixedMul(dx, delta);
|
||||
dy = FixedMul(dy, delta);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dx && !dy)
|
||||
continue;
|
||||
|
||||
switch(s->type)
|
||||
{
|
||||
side_t *side;
|
||||
sector_t *sec;
|
||||
|
||||
case sc_side:
|
||||
side = sides + s->affectee;
|
||||
side->textureoffset = side->basetextureoffset + FixedMul(dx, fractionaltic);
|
||||
side->rowoffset = side->baserowoffset + FixedMul(dy, fractionaltic);
|
||||
break;
|
||||
case sc_floor:
|
||||
sec = sectors + s->affectee;
|
||||
sec->floor_xoffs = sec->base_floor_xoffs + FixedMul(dx, fractionaltic);
|
||||
sec->floor_yoffs = sec->base_floor_yoffs + FixedMul(dy, fractionaltic);
|
||||
break;
|
||||
case sc_ceiling:
|
||||
sec = sectors + s->affectee;
|
||||
sec->ceiling_xoffs = sec->base_ceiling_xoffs + FixedMul(dx, fractionaltic);
|
||||
sec->ceiling_yoffs = sec->base_ceiling_yoffs + FixedMul(dy, fractionaltic);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add_Scroller()
|
||||
//
|
||||
@ -2813,9 +2746,6 @@ static void Add_Scroller(int type, fixed_t dx, fixed_t dy,
|
||||
sectors[control].floorheight + sectors[control].ceilingheight;
|
||||
s->affectee = affectee;
|
||||
P_AddThinker(&s->thinker);
|
||||
|
||||
if (type >= sc_side && type <= sc_ceiling)
|
||||
P_AddScroller(s);
|
||||
}
|
||||
|
||||
// Adds wall scroller. Scroll amount is rotated with respect to wall's
|
||||
@ -2855,8 +2785,6 @@ static void P_SpawnScrollers(void)
|
||||
int i;
|
||||
line_t *l = lines;
|
||||
|
||||
P_FreeScrollers();
|
||||
|
||||
for (i=0;i<numlines;i++,l++)
|
||||
{
|
||||
fixed_t dx = l->dx >> SCROLL_SHIFT; // direction and speed of scrolling
|
||||
|
@ -810,10 +810,6 @@ boolean P_WasSecret(sector_t *sec);
|
||||
|
||||
void P_ChangeSwitchTexture(line_t *line, int useAgain);
|
||||
|
||||
void P_FreeScrollers(void);
|
||||
|
||||
void P_AddScroller(scroll_t *s);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Linedef and sector special action function prototypes
|
||||
|
25
src/r_bsp.c
25
src/r_bsp.c
@ -294,6 +294,18 @@ static void R_MaybeInterpolateSector(sector_t* sector)
|
||||
{
|
||||
sector->interpceilingheight = sector->ceilingheight;
|
||||
}
|
||||
|
||||
if (sector->oldscrollgametic == gametic - 1)
|
||||
{
|
||||
sector->floor_xoffs = sector->old_floor_xoffs +
|
||||
FixedMul(sector->base_floor_xoffs - sector->old_floor_xoffs, fractionaltic);
|
||||
sector->floor_yoffs = sector->old_floor_yoffs +
|
||||
FixedMul(sector->base_floor_yoffs - sector->old_floor_yoffs, fractionaltic);
|
||||
sector->ceiling_xoffs = sector->old_ceiling_xoffs +
|
||||
FixedMul(sector->base_ceiling_xoffs - sector->old_ceiling_xoffs, fractionaltic);
|
||||
sector->ceiling_yoffs = sector->old_ceiling_yoffs +
|
||||
FixedMul(sector->base_ceiling_yoffs - sector->old_ceiling_yoffs, fractionaltic);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -302,6 +314,17 @@ static void R_MaybeInterpolateSector(sector_t* sector)
|
||||
}
|
||||
}
|
||||
|
||||
static void R_MaybeInterpolateTextureOffsets(side_t *side)
|
||||
{
|
||||
if (uncapped && side->oldgametic == gametic - 1)
|
||||
{
|
||||
side->textureoffset = side->oldtextureoffset +
|
||||
FixedMul(side->basetextureoffset - side->oldtextureoffset, fractionaltic);
|
||||
side->rowoffset = side->oldrowoffset +
|
||||
FixedMul(side->baserowoffset - side->oldrowoffset, fractionaltic);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// R_AddLine
|
||||
// Clips the given segment
|
||||
@ -372,6 +395,8 @@ static void R_AddLine (seg_t *line)
|
||||
if (x1 >= x2) // killough 1/31/98 -- change == to >= for robustness
|
||||
return;
|
||||
|
||||
R_MaybeInterpolateTextureOffsets(line->sidedef);
|
||||
|
||||
backsector = line->backsector;
|
||||
|
||||
// Single sided line?
|
||||
|
@ -153,6 +153,7 @@ typedef struct
|
||||
// if old values were not updated recently.
|
||||
int oldceilgametic;
|
||||
int oldfloorgametic;
|
||||
int oldscrollgametic;
|
||||
|
||||
// [AM] Interpolated floor and ceiling height.
|
||||
// Calculated once per tic and used inside
|
||||
@ -162,8 +163,12 @@ typedef struct
|
||||
|
||||
fixed_t base_floor_xoffs;
|
||||
fixed_t base_floor_yoffs;
|
||||
fixed_t old_floor_xoffs;
|
||||
fixed_t old_floor_yoffs;
|
||||
fixed_t base_ceiling_xoffs;
|
||||
fixed_t base_ceiling_yoffs;
|
||||
fixed_t old_ceiling_xoffs;
|
||||
fixed_t old_ceiling_yoffs;
|
||||
} sector_t;
|
||||
|
||||
//
|
||||
@ -186,8 +191,11 @@ typedef struct
|
||||
int special;
|
||||
|
||||
// [crispy] smooth texture scrolling
|
||||
fixed_t oldtextureoffset;
|
||||
fixed_t oldrowoffset;
|
||||
fixed_t basetextureoffset;
|
||||
fixed_t baserowoffset;
|
||||
int oldgametic;
|
||||
|
||||
} side_t;
|
||||
|
||||
|
@ -816,9 +816,6 @@ void R_RenderPlayerView (player_t* player)
|
||||
// check for new console commands.
|
||||
NetUpdate ();
|
||||
|
||||
// [crispy] smooth texture scrolling
|
||||
R_InterpolateTextureOffsets();
|
||||
|
||||
// The head node is the last node output.
|
||||
R_RenderBSPNode (numnodes-1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user