Core/Clock: Restart now returns the elapsed time in milliseconds
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user