- changed I_GetTimeFrac to return a double instead of a fixed_t.

This commit is contained in:
Christoph Oelckers 2016-03-24 12:00:21 +01:00
parent c83ad9df6c
commit 09d8b4af80
6 changed files with 13 additions and 15 deletions

View file

@ -186,7 +186,7 @@ unsigned int I_FPSTime()
}
fixed_t I_GetTimeFrac(uint32* ms)
double I_GetTimeFrac(uint32* ms)
{
const uint32_t now = I_MSTime();
@ -196,8 +196,8 @@ fixed_t I_GetTimeFrac(uint32* ms)
}
return 0 == s_ticStart
? FRACUNIT
: clamp<fixed_t>( (now - s_ticStart) * FRACUNIT * TICRATE / 1000, 0, FRACUNIT);
? 1.
: clamp<double>( (now - s_ticStart) * TICRATE / 1000., 0, 1);
}

View file

@ -62,7 +62,7 @@ extern int (*I_WaitForTic) (int);
// tic will never arrive (unless it's the current one).
extern void (*I_FreezeTime) (bool frozen);
fixed_t I_GetTimeFrac (uint32 *ms);
double I_GetTimeFrac (uint32 *ms);
// Return a seed value for the RNG.
unsigned int I_MakeRNGSeed();

View file

@ -178,7 +178,7 @@ void I_SelectTimer()
}
// Returns the fractional amount of a tic passed since the most recent tic
fixed_t I_GetTimeFrac (uint32 *ms)
double I_GetTimeFrac (uint32 *ms)
{
DWORD now = SDL_GetTicks ();
if (ms) *ms = TicStart + (1000 / TICRATE);
@ -188,8 +188,7 @@ fixed_t I_GetTimeFrac (uint32 *ms)
}
else
{
fixed_t frac = clamp<fixed_t> ((now - TicStart)*FRACUNIT*TICRATE/1000, 0, FRACUNIT);
return frac;
return clamp<double>((now - TicStart) * TICRATE / 1000., 0, 1);
}
}

View file

@ -1006,12 +1006,12 @@ void R_SetupFrame (AActor *actor)
iview->otic = nowtic;
}
r_TicFrac = I_GetTimeFrac (&r_FrameTime);
r_TicFracF = I_GetTimeFrac (&r_FrameTime);
if (cl_capfps || r_NoInterpolate)
{
r_TicFrac = FRACUNIT;
r_TicFracF = 1.;
}
r_TicFracF = FIXED2DBL(r_TicFrac);
r_TicFrac = FLOAT2FIXED(r_TicFracF);
R_InterpolateView (player, r_TicFrac, iview);

View file

@ -468,7 +468,7 @@ static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw
//
//==========================================================================
fixed_t I_GetTimeFrac(uint32 *ms)
double I_GetTimeFrac(uint32 *ms)
{
DWORD now = timeGetTime();
if (ms != NULL)
@ -478,12 +478,11 @@ fixed_t I_GetTimeFrac(uint32 *ms)
DWORD step = TicNext - TicStart;
if (step == 0)
{
return FRACUNIT;
return 1.;
}
else
{
fixed_t frac = clamp<fixed_t> ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT);
return frac;
return clamp<double>(double(now - TicStart) / step, 0, 1);
}
}

View file

@ -90,7 +90,7 @@ extern int (*I_WaitForTic) (int);
// tic will never arrive (unless it's the current one).
extern void (*I_FreezeTime) (bool frozen);
fixed_t I_GetTimeFrac (uint32 *ms);
double I_GetTimeFrac (uint32 *ms);
// Return a seed value for the RNG.
unsigned int I_MakeRNGSeed();