Core/Clock: Restart now returns the elapsed time in milliseconds

This commit is contained in:
Jérôme Leclercq
2018-02-07 15:02:44 +01:00
parent b855dcb17e
commit fb3eb9443e
6 changed files with 20 additions and 12 deletions

View File

@@ -67,7 +67,7 @@ namespace Nz
*/
float Clock::GetSeconds() const
{
return GetMicroseconds()/1000000.f;
return GetMicroseconds()/1'000'000.f;
}
/*!
@@ -132,15 +132,26 @@ namespace Nz
/*!
* \brief Restart the clock
* \return Microseconds elapsed
*
* Restarts the clock, putting it's time counter back to zero (as if the clock got constructed).
* It also compute the elapsed microseconds since the last Restart() call without any time loss (a problem that the combination of GetElapsedMicroseconds and Restart have).
*/
void Clock::Restart()
UInt64 Clock::Restart()
{
NazaraLock(m_mutex);
Nz::UInt64 now = GetElapsedMicroseconds();
Nz::UInt64 elapsedTime = m_elapsedTime;
if (!m_paused)
elapsedTime += (now - m_refTime);
m_elapsedTime = 0;
m_refTime = GetElapsedMicroseconds();
m_refTime = now;
m_paused = false;
return elapsedTime;
}
/*!