mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 15:08:19 +00:00
Make menu background animations smoother
time_get_microseconds() count starts from 1970-01-01 and float's precision is not enough for every 1/60 of a second. I'm replacing it with LocalTime() - it's also available in the menu and it's counted from the start of the game. I've tested menu and in-game animations.
This commit is contained in:
parent
6990cf3a0d
commit
88c31a4711
|
@ -116,24 +116,18 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
|
|||
{
|
||||
if(pThis->m_OnlineOnly && (pItem->m_Version < 2 || pItem->m_Synchronized))
|
||||
{
|
||||
if(pThis->m_OnlineOnly && pThis->m_pClient->m_Snap.m_pGameInfoObj) // && !(pThis->m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED))
|
||||
if(pThis->m_pClient->m_Snap.m_pGameInfoObj) // && !(pThis->m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED))
|
||||
{
|
||||
s_Time = mix((pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(),
|
||||
(pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(),
|
||||
pThis->Client()->IntraGameTick(g_Config.m_ClDummy));
|
||||
}
|
||||
}
|
||||
else if(pThis->m_OnlineOnly)
|
||||
else
|
||||
{
|
||||
s_Time += pThis->LocalTime() - s_LastLocalTime;
|
||||
s_LastLocalTime = pThis->LocalTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
float CurTime = (float)((double)time_get_microseconds() / 1000000.0);
|
||||
s_Time += CurTime - s_LastLocalTime;
|
||||
s_LastLocalTime = CurTime;
|
||||
}
|
||||
pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, s_Time + TimeOffset, pChannels);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue