mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 02:42:20 +00:00
Add smooth level platter under interpolation, renderdeltatics
`renderdeltatics` can be used as a standard delta time in any place, allowing for smooth menus. It will always be equal to `realtics` when frame interpolation is turned off, producing consistent framerate behavior everywhere it is used.
This commit is contained in:
parent
722b04518d
commit
61efef2fa9
6 changed files with 54 additions and 28 deletions
17
src/d_main.c
17
src/d_main.c
|
@ -148,7 +148,6 @@ event_t events[MAXEVENTS];
|
|||
INT32 eventhead, eventtail;
|
||||
|
||||
boolean dedicated = false;
|
||||
boolean tic_happened = false; // Frame interpolation/uncapped
|
||||
|
||||
//
|
||||
// D_PostEvent
|
||||
|
@ -782,13 +781,25 @@ void D_SRB2Loop(void)
|
|||
realtics = 1;
|
||||
|
||||
// process tics (but maybe not if realtic == 0)
|
||||
tic_happened = realtics ? true : false;
|
||||
TryRunTics(realtics);
|
||||
|
||||
if (cv_frameinterpolation.value == 1)
|
||||
rendertimefrac = I_GetTimeFrac();
|
||||
{
|
||||
fixed_t entertimefrac = I_GetTimeFrac();
|
||||
// renderdeltatics is a bit awkard to evaluate, since the system time interface is whole tic-based
|
||||
renderdeltatics = realtics * FRACUNIT;
|
||||
if (entertimefrac > rendertimefrac)
|
||||
renderdeltatics += entertimefrac - rendertimefrac;
|
||||
else
|
||||
renderdeltatics -= rendertimefrac - entertimefrac;
|
||||
|
||||
rendertimefrac = entertimefrac;
|
||||
}
|
||||
else
|
||||
{
|
||||
rendertimefrac = FRACUNIT;
|
||||
renderdeltatics = realtics * FRACUNIT;
|
||||
}
|
||||
|
||||
if (cv_frameinterpolation.value == 1)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,6 @@ extern char srb2home[256]; //Alam: My Home
|
|||
extern boolean usehome; //Alam: which path?
|
||||
extern const char *pandf; //Alam: how to path?
|
||||
extern char srb2path[256]; //Alam: SRB2's Home
|
||||
extern boolean tic_happened; // Frame interpolation/uncapped
|
||||
|
||||
// the infinite loop of D_SRB2Loop() called from win_main for windows version
|
||||
void D_SRB2Loop(void) FUNCNORETURN;
|
||||
|
|
|
@ -6714,7 +6714,7 @@ void HWR_DoPostProcessor(player_t *player)
|
|||
// 10 by 10 grid. 2 coordinates (xy)
|
||||
float v[SCREENVERTS][SCREENVERTS][2];
|
||||
static double disStart = 0;
|
||||
static float last_fractime = 0;
|
||||
static fixed_t last_fractime = 0;
|
||||
|
||||
UINT8 x, y;
|
||||
INT32 WAVELENGTH;
|
||||
|
@ -6747,16 +6747,15 @@ void HWR_DoPostProcessor(player_t *player)
|
|||
HWD.pfnPostImgRedraw(v);
|
||||
if (!(paused || P_AutoPause()))
|
||||
disStart += 1;
|
||||
fixed_t fractime = I_GetTimeFrac();
|
||||
if (tic_happened)
|
||||
if (renderdeltatics > FRACUNIT)
|
||||
{
|
||||
disStart = disStart - last_fractime + 1 + FIXED_TO_FLOAT(fractime);
|
||||
disStart = disStart - FIXED_TO_FLOAT(last_fractime) + 1 + FIXED_TO_FLOAT(rendertimefrac);
|
||||
}
|
||||
else
|
||||
{
|
||||
disStart = disStart - last_fractime + FIXED_TO_FLOAT(fractime);
|
||||
disStart = disStart - FIXED_TO_FLOAT(last_fractime) + FIXED_TO_FLOAT(rendertimefrac);
|
||||
}
|
||||
last_fractime = fractime;
|
||||
last_fractime = rendertimefrac;
|
||||
|
||||
// Capture the screen again for screen waving on the intermission
|
||||
if(gamestate != GS_INTERMISSION)
|
||||
|
|
49
src/m_menu.c
49
src/m_menu.c
|
@ -207,17 +207,17 @@ menu_t SPauseDef;
|
|||
static levelselect_t levelselect = {0, NULL};
|
||||
static UINT8 levelselectselect[3];
|
||||
static patch_t *levselp[2][3];
|
||||
static INT32 lsoffs[2];
|
||||
static fixed_t lsoffs[2];
|
||||
|
||||
#define lsrow levelselectselect[0]
|
||||
#define lscol levelselectselect[1]
|
||||
#define lshli levelselectselect[2]
|
||||
|
||||
#define lshseperation 101
|
||||
#define lsbasevseperation (62*vid.height)/(BASEVIDHEIGHT*vid.dupy) //62
|
||||
#define lsbasevseperation ((62*vid.height)/(BASEVIDHEIGHT*vid.dupy)) //62
|
||||
#define lsheadingheight 16
|
||||
#define getheadingoffset(row) (levelselect.rows[row].header[0] ? lsheadingheight : 0)
|
||||
#define lsvseperation(row) lsbasevseperation + getheadingoffset(row)
|
||||
#define lsvseperation(row) (lsbasevseperation + getheadingoffset(row))
|
||||
#define lswide(row) levelselect.rows[row].mapavailable[3]
|
||||
|
||||
#define lsbasex 19
|
||||
|
@ -5504,7 +5504,7 @@ static void M_HandleLevelPlatter(INT32 choice)
|
|||
{
|
||||
if (!lsoffs[0]) // prevent sound spam
|
||||
{
|
||||
lsoffs[0] = -8;
|
||||
lsoffs[0] = -8 * FRACUNIT;
|
||||
S_StartSound(NULL,sfx_s3kb7);
|
||||
}
|
||||
return;
|
||||
|
@ -5513,7 +5513,7 @@ static void M_HandleLevelPlatter(INT32 choice)
|
|||
}
|
||||
lsrow++;
|
||||
|
||||
lsoffs[0] = lsvseperation(lsrow);
|
||||
lsoffs[0] = lsvseperation(lsrow) * FRACUNIT;
|
||||
|
||||
if (levelselect.rows[lsrow].header[0])
|
||||
lshli = lsrow;
|
||||
|
@ -5532,7 +5532,7 @@ static void M_HandleLevelPlatter(INT32 choice)
|
|||
{
|
||||
if (!lsoffs[0]) // prevent sound spam
|
||||
{
|
||||
lsoffs[0] = 8;
|
||||
lsoffs[0] = 8 * FRACUNIT;
|
||||
S_StartSound(NULL,sfx_s3kb7);
|
||||
}
|
||||
return;
|
||||
|
@ -5541,7 +5541,7 @@ static void M_HandleLevelPlatter(INT32 choice)
|
|||
}
|
||||
lsrow--;
|
||||
|
||||
lsoffs[0] = -lsvseperation(iter);
|
||||
lsoffs[0] = -lsvseperation(iter) * FRACUNIT;
|
||||
|
||||
if (levelselect.rows[lsrow].header[0])
|
||||
lshli = lsrow;
|
||||
|
@ -5582,7 +5582,7 @@ static void M_HandleLevelPlatter(INT32 choice)
|
|||
}
|
||||
else if (!lsoffs[0]) // prevent sound spam
|
||||
{
|
||||
lsoffs[0] = -8;
|
||||
lsoffs[0] = -8 * FRACUNIT;
|
||||
S_StartSound(NULL,sfx_s3kb2);
|
||||
}
|
||||
break;
|
||||
|
@ -5608,14 +5608,14 @@ static void M_HandleLevelPlatter(INT32 choice)
|
|||
{
|
||||
lscol++;
|
||||
|
||||
lsoffs[1] = (lswide(lsrow) ? 8 : -lshseperation);
|
||||
lsoffs[1] = (lswide(lsrow) ? 8 : -lshseperation) * FRACUNIT;
|
||||
S_StartSound(NULL,sfx_s3kb7);
|
||||
|
||||
ifselectvalnextmap(lscol) else ifselectvalnextmap(0)
|
||||
}
|
||||
else if (!lsoffs[1]) // prevent sound spam
|
||||
{
|
||||
lsoffs[1] = 8;
|
||||
lsoffs[1] = 8 * FRACUNIT;
|
||||
S_StartSound(NULL,sfx_s3kb7);
|
||||
}
|
||||
break;
|
||||
|
@ -5640,14 +5640,14 @@ static void M_HandleLevelPlatter(INT32 choice)
|
|||
{
|
||||
lscol--;
|
||||
|
||||
lsoffs[1] = (lswide(lsrow) ? -8 : lshseperation);
|
||||
lsoffs[1] = (lswide(lsrow) ? -8 : lshseperation) * FRACUNIT;
|
||||
S_StartSound(NULL,sfx_s3kb7);
|
||||
|
||||
ifselectvalnextmap(lscol) else ifselectvalnextmap(0)
|
||||
}
|
||||
else if (!lsoffs[1]) // prevent sound spam
|
||||
{
|
||||
lsoffs[1] = -8;
|
||||
lsoffs[1] = -8 * FRACUNIT;
|
||||
S_StartSound(NULL,sfx_s3kb7);
|
||||
}
|
||||
break;
|
||||
|
@ -5946,7 +5946,7 @@ static void M_DrawNightsAttackSuperSonic(void)
|
|||
static void M_DrawLevelPlatterMenu(void)
|
||||
{
|
||||
UINT8 iter = lsrow, sizeselect = (lswide(lsrow) ? 1 : 0);
|
||||
INT32 y = lsbasey + lsoffs[0] - getheadingoffset(lsrow);
|
||||
INT32 y = lsbasey + FixedInt(lsoffs[0]) - getheadingoffset(lsrow);
|
||||
const INT32 cursorx = (sizeselect ? 0 : (lscol*lshseperation));
|
||||
|
||||
if (currentMenu->prevMenu == &SP_TimeAttackDef)
|
||||
|
@ -6014,7 +6014,7 @@ static void M_DrawLevelPlatterMenu(void)
|
|||
|
||||
// draw cursor box
|
||||
if (levellistmode != LLM_CREATESERVER || lsrow)
|
||||
V_DrawSmallScaledPatch(lsbasex + cursorx + lsoffs[1], lsbasey+lsoffs[0], 0, (levselp[sizeselect][((skullAnimCounter/4) ? 1 : 0)]));
|
||||
V_DrawSmallScaledPatch(lsbasex + cursorx + FixedInt(lsoffs[1]), lsbasey+FixedInt(lsoffs[0]), 0, (levselp[sizeselect][((skullAnimCounter/4) ? 1 : 0)]));
|
||||
|
||||
#if 0
|
||||
if (levelselect.rows[lsrow].maplist[lscol] > 0)
|
||||
|
@ -6022,13 +6022,26 @@ static void M_DrawLevelPlatterMenu(void)
|
|||
#endif
|
||||
|
||||
// handle movement of cursor box
|
||||
if (lsoffs[0] > 1 || lsoffs[0] < -1)
|
||||
lsoffs[0] = 2*lsoffs[0]/3;
|
||||
fixed_t cursormovefrac = FixedDiv(2, 3);
|
||||
if (lsoffs[0] > FRACUNIT || lsoffs[0] < -FRACUNIT)
|
||||
{
|
||||
fixed_t offs = lsoffs[0];
|
||||
fixed_t newoffs = FixedMul(offs, cursormovefrac);
|
||||
fixed_t deltaoffs = newoffs - offs;
|
||||
newoffs = offs + FixedMul(deltaoffs, renderdeltatics);
|
||||
lsoffs[0] = newoffs;
|
||||
}
|
||||
else
|
||||
lsoffs[0] = 0;
|
||||
|
||||
if (lsoffs[1] > 1 || lsoffs[1] < -1)
|
||||
lsoffs[1] = 2*lsoffs[1]/3;
|
||||
if (lsoffs[1] > FRACUNIT || lsoffs[1] < -FRACUNIT)
|
||||
{
|
||||
fixed_t offs = lsoffs[1];
|
||||
fixed_t newoffs = FixedMul(offs, cursormovefrac);
|
||||
fixed_t deltaoffs = newoffs - offs;
|
||||
newoffs = offs + FixedMul(deltaoffs, renderdeltatics);
|
||||
lsoffs[1] = newoffs;
|
||||
}
|
||||
else
|
||||
lsoffs[1] = 0;
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ player_t *viewplayer;
|
|||
mobj_t *r_viewmobj;
|
||||
|
||||
fixed_t rendertimefrac;
|
||||
fixed_t renderdeltatics;
|
||||
|
||||
//
|
||||
// precalculated math tables
|
||||
|
|
|
@ -35,7 +35,10 @@ extern fixed_t fovtan;
|
|||
|
||||
extern size_t validcount, linecount, loopcount, framecount;
|
||||
|
||||
// The fraction of a tic being drawn (for interpolation between two tics)
|
||||
extern fixed_t rendertimefrac;
|
||||
// Evaluated delta tics for this frame (how many tics since the last frame)
|
||||
extern fixed_t renderdeltatics;;
|
||||
|
||||
//
|
||||
// Lighting LUT.
|
||||
|
|
Loading…
Reference in a new issue