diff --git a/src/d_main.c b/src/d_main.c index f611c4c3f..d24cc4b58 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -155,7 +155,6 @@ event_t events[MAXEVENTS]; INT32 eventhead, eventtail; boolean dedicated = false; -boolean tic_happened = false; // Frame interpolation/uncapped // // D_PostEvent @@ -773,13 +772,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) { diff --git a/src/d_main.h b/src/d_main.h index 26b5c4528..81de0634d 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -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; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 997978a31..e3f56f831 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6687,7 +6687,6 @@ INT32 HWR_GetTextureUsed(void) void HWR_DoPostProcessor(player_t *player) { postimg_t *type = &postimgtype[0]; - fixed_t fractime; SINT8 i; HWD.pfnUnSetShader(); @@ -6739,7 +6738,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; @@ -6772,16 +6771,15 @@ void HWR_DoPostProcessor(player_t *player) HWD.pfnPostImgRedraw(v); if (!(paused || P_AutoPause())) disStart += 1; - 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) diff --git a/src/r_main.c b/src/r_main.c index 6cb05801c..231bde280 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -81,6 +81,7 @@ mobj_t *r_viewmobj; int r_splitscreen; fixed_t rendertimefrac; +fixed_t renderdeltatics; // // precalculated math tables diff --git a/src/r_main.h b/src/r_main.h index 2ddec0ff1..a2acf60d9 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -33,7 +33,10 @@ extern fixed_t fovtan[MAXSPLITSCREENPLAYERS]; 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.