mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Menu 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. Co-Authored-By: Eidolon <furyhunter600@gmail.com>
This commit is contained in:
parent
5325431450
commit
f16b567319
5 changed files with 23 additions and 11 deletions
17
src/d_main.c
17
src/d_main.c
|
|
@ -155,7 +155,6 @@ event_t events[MAXEVENTS];
|
||||||
INT32 eventhead, eventtail;
|
INT32 eventhead, eventtail;
|
||||||
|
|
||||||
boolean dedicated = false;
|
boolean dedicated = false;
|
||||||
boolean tic_happened = false; // Frame interpolation/uncapped
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// D_PostEvent
|
// D_PostEvent
|
||||||
|
|
@ -773,13 +772,25 @@ void D_SRB2Loop(void)
|
||||||
realtics = 1;
|
realtics = 1;
|
||||||
|
|
||||||
// process tics (but maybe not if realtic == 0)
|
// process tics (but maybe not if realtic == 0)
|
||||||
tic_happened = realtics ? true : false;
|
|
||||||
TryRunTics(realtics);
|
TryRunTics(realtics);
|
||||||
|
|
||||||
if (cv_frameinterpolation.value == 1)
|
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
|
else
|
||||||
|
{
|
||||||
rendertimefrac = FRACUNIT;
|
rendertimefrac = FRACUNIT;
|
||||||
|
renderdeltatics = realtics * FRACUNIT;
|
||||||
|
}
|
||||||
|
|
||||||
if (cv_frameinterpolation.value == 1)
|
if (cv_frameinterpolation.value == 1)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ extern char srb2home[256]; //Alam: My Home
|
||||||
extern boolean usehome; //Alam: which path?
|
extern boolean usehome; //Alam: which path?
|
||||||
extern const char *pandf; //Alam: how to path?
|
extern const char *pandf; //Alam: how to path?
|
||||||
extern char srb2path[256]; //Alam: SRB2's Home
|
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
|
// the infinite loop of D_SRB2Loop() called from win_main for windows version
|
||||||
void D_SRB2Loop(void) FUNCNORETURN;
|
void D_SRB2Loop(void) FUNCNORETURN;
|
||||||
|
|
|
||||||
|
|
@ -6687,7 +6687,6 @@ INT32 HWR_GetTextureUsed(void)
|
||||||
void HWR_DoPostProcessor(player_t *player)
|
void HWR_DoPostProcessor(player_t *player)
|
||||||
{
|
{
|
||||||
postimg_t *type = &postimgtype[0];
|
postimg_t *type = &postimgtype[0];
|
||||||
fixed_t fractime;
|
|
||||||
SINT8 i;
|
SINT8 i;
|
||||||
|
|
||||||
HWD.pfnUnSetShader();
|
HWD.pfnUnSetShader();
|
||||||
|
|
@ -6739,7 +6738,7 @@ void HWR_DoPostProcessor(player_t *player)
|
||||||
// 10 by 10 grid. 2 coordinates (xy)
|
// 10 by 10 grid. 2 coordinates (xy)
|
||||||
float v[SCREENVERTS][SCREENVERTS][2];
|
float v[SCREENVERTS][SCREENVERTS][2];
|
||||||
static double disStart = 0;
|
static double disStart = 0;
|
||||||
static float last_fractime = 0;
|
static fixed_t last_fractime = 0;
|
||||||
|
|
||||||
UINT8 x, y;
|
UINT8 x, y;
|
||||||
INT32 WAVELENGTH;
|
INT32 WAVELENGTH;
|
||||||
|
|
@ -6772,16 +6771,15 @@ void HWR_DoPostProcessor(player_t *player)
|
||||||
HWD.pfnPostImgRedraw(v);
|
HWD.pfnPostImgRedraw(v);
|
||||||
if (!(paused || P_AutoPause()))
|
if (!(paused || P_AutoPause()))
|
||||||
disStart += 1;
|
disStart += 1;
|
||||||
fractime = I_GetTimeFrac();
|
if (renderdeltatics > FRACUNIT)
|
||||||
if (tic_happened)
|
|
||||||
{
|
{
|
||||||
disStart = disStart - last_fractime + 1 + FIXED_TO_FLOAT(fractime);
|
disStart = disStart - FIXED_TO_FLOAT(last_fractime) + 1 + FIXED_TO_FLOAT(rendertimefrac);
|
||||||
}
|
}
|
||||||
else
|
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
|
// Capture the screen again for screen waving on the intermission
|
||||||
if(gamestate != GS_INTERMISSION)
|
if(gamestate != GS_INTERMISSION)
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ mobj_t *r_viewmobj;
|
||||||
int r_splitscreen;
|
int r_splitscreen;
|
||||||
|
|
||||||
fixed_t rendertimefrac;
|
fixed_t rendertimefrac;
|
||||||
|
fixed_t renderdeltatics;
|
||||||
|
|
||||||
//
|
//
|
||||||
// precalculated math tables
|
// precalculated math tables
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,10 @@ extern fixed_t fovtan[MAXSPLITSCREENPLAYERS];
|
||||||
|
|
||||||
extern size_t validcount, linecount, loopcount, framecount;
|
extern size_t validcount, linecount, loopcount, framecount;
|
||||||
|
|
||||||
|
// The fraction of a tic being drawn (for interpolation between two tics)
|
||||||
extern fixed_t rendertimefrac;
|
extern fixed_t rendertimefrac;
|
||||||
|
// Evaluated delta tics for this frame (how many tics since the last frame)
|
||||||
|
extern fixed_t renderdeltatics;;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Lighting LUT.
|
// Lighting LUT.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue