mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 19:38:06 -04:00
add smooth texture scrolling from Crispy Doom (#731)
* add smooth texture scrolling from Crispy Doom
* add forgotten baserowoffset initialization
Good catch, eagle eye 😉 @kraflab
* iterate through a list of scrollers separate from the thinker list
* add forgotten parenthesis
* fix another typo (yes, this is a blind lunch break coding session)
* consider friendly suggestions
* Implement a clean interface for cleaning the side scrollers list (@kraflab)
* Allocate scrollers in chunks of 32 (VANILLA limit is 64) (@rfomin)
Thanks!
This commit is contained in:
parent
a24c5955c9
commit
347e430c71
@ -2086,6 +2086,9 @@ void P_UnArchiveWorld (void)
|
||||
|
||||
si->textureoffset = saveg_read32();
|
||||
si->rowoffset = saveg_read32();
|
||||
// [crispy] smooth texture scrolling
|
||||
si->basetextureoffset = si->textureoffset;
|
||||
si->baserowoffset = si->rowoffset;
|
||||
|
||||
si->toptexture = saveg_read16();
|
||||
si->bottomtexture = saveg_read16();
|
||||
|
@ -577,6 +577,9 @@ void P_LoadSideDefs2(int lump)
|
||||
|
||||
sd->textureoffset = SHORT(msd->textureoffset)<<FRACBITS;
|
||||
sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS;
|
||||
// [crispy] smooth texture scrolling
|
||||
sd->basetextureoffset = sd->textureoffset;
|
||||
sd->baserowoffset = sd->rowoffset;
|
||||
|
||||
// killough 4/4/98: allow sidedef texture names to be overloaded
|
||||
// killough 4/11/98: refined to allow colormaps to work as wall
|
||||
|
53
src/p_spec.c
53
src/p_spec.c
@ -56,6 +56,7 @@
|
||||
#include "r_draw.h" // R_SetFuzzPosTic
|
||||
#include "r_sky.h" // R_GetSkyColor
|
||||
#include "m_swap.h"
|
||||
#include "i_video.h" // [FG] uncapped
|
||||
|
||||
//
|
||||
// Animating textures and planes
|
||||
@ -2591,8 +2592,10 @@ void T_Scroll(scroll_t *s)
|
||||
|
||||
case sc_side: // killough 3/7/98: Scroll wall texture
|
||||
side = sides + s->affectee;
|
||||
side->textureoffset += dx;
|
||||
side->rowoffset += dy;
|
||||
side->basetextureoffset += dx;
|
||||
side->baserowoffset += dy;
|
||||
side->textureoffset = side->basetextureoffset;
|
||||
side->rowoffset = side->baserowoffset;
|
||||
break;
|
||||
|
||||
case sc_floor: // killough 3/7/98: Scroll floor texture
|
||||
@ -2638,6 +2641,47 @@ void T_Scroll(scroll_t *s)
|
||||
}
|
||||
}
|
||||
|
||||
// [crispy] smooth texture scrolling
|
||||
|
||||
static int maxsidescrollers, numsidescrollers;
|
||||
static scroll_t **sidescrollers;
|
||||
|
||||
static void P_AddSideScroller (scroll_t *s)
|
||||
{
|
||||
if (numsidescrollers == maxsidescrollers)
|
||||
{
|
||||
maxsidescrollers = maxsidescrollers ? 2 * maxsidescrollers : 32;
|
||||
sidescrollers = I_Realloc(sidescrollers, maxsidescrollers * sizeof(*sidescrollers));
|
||||
}
|
||||
sidescrollers[numsidescrollers++] = s;
|
||||
}
|
||||
|
||||
static void P_FreeSideScrollers (void)
|
||||
{
|
||||
maxsidescrollers = 0;
|
||||
numsidescrollers = 0;
|
||||
if (sidescrollers)
|
||||
free(sidescrollers);
|
||||
sidescrollers = NULL;
|
||||
}
|
||||
|
||||
void R_InterpolateTextureOffsets (void)
|
||||
{
|
||||
if (uncapped && leveltime > oldleveltime)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numsidescrollers; i++)
|
||||
{
|
||||
scroll_t *s = sidescrollers[i];
|
||||
side_t *side = sides + s->affectee;
|
||||
|
||||
side->textureoffset = side->basetextureoffset + FixedMul(s->dx, fractionaltic);
|
||||
side->rowoffset = side->baserowoffset + FixedMul(s->dy, fractionaltic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add_Scroller()
|
||||
//
|
||||
@ -2671,6 +2715,9 @@ 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)
|
||||
P_AddSideScroller(s);
|
||||
}
|
||||
|
||||
// Adds wall scroller. Scroll amount is rotated with respect to wall's
|
||||
@ -2710,6 +2757,8 @@ static void P_SpawnScrollers(void)
|
||||
int i;
|
||||
line_t *l = lines;
|
||||
|
||||
P_FreeSideScrollers();
|
||||
|
||||
for (i=0;i<numlines;i++,l++)
|
||||
{
|
||||
fixed_t dx = l->dx >> SCROLL_SHIFT; // direction and speed of scrolling
|
||||
|
@ -189,6 +189,10 @@ typedef struct
|
||||
|
||||
int special;
|
||||
|
||||
// [crispy] smooth texture scrolling
|
||||
fixed_t basetextureoffset;
|
||||
fixed_t baserowoffset;
|
||||
|
||||
} side_t;
|
||||
|
||||
//
|
||||
|
@ -814,6 +814,9 @@ 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);
|
||||
|
||||
|
@ -123,6 +123,9 @@ void R_InitLightTables(void); // killough 8/9/98
|
||||
extern boolean setsizeneeded;
|
||||
void R_ExecuteSetViewSize(void);
|
||||
|
||||
// [crispy] smooth texture scrolling
|
||||
void R_InterpolateTextureOffsets (void);
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user