allow b3Clock to reset to time reference 0, by default reset will set the reference to 'now'.

This commit is contained in:
Erwin Coumans
2017-06-02 08:18:17 -07:00
parent 3987bdd333
commit 5a89b4f385
2 changed files with 19 additions and 3 deletions

View File

@@ -88,7 +88,22 @@ b3Clock& b3Clock::operator=(const b3Clock& other)
/// Resets the initial reference time. /// Resets the initial reference time.
void b3Clock::reset() void b3Clock::reset(bool zeroReference)
{
if (zeroReference)
{
m_data->mStartTick = 0;
#ifdef B3_USE_WINDOWS_TIMERS
m_data->mStartTime.QuadPart = 0;
#else
#ifdef __CELLOS_LV2__
m_data->mStartTime = 0;
#else
m_data->mStartTime = (struct timeval){0};
#endif
#endif
} else
{ {
#ifdef B3_USE_WINDOWS_TIMERS #ifdef B3_USE_WINDOWS_TIMERS
QueryPerformanceCounter(&m_data->mStartTime); QueryPerformanceCounter(&m_data->mStartTime);
@@ -106,6 +121,7 @@ void b3Clock::reset()
#endif #endif
#endif #endif
} }
}
/// Returns the time in ms since the last call to reset or since /// Returns the time in ms since the last call to reset or since
/// the b3Clock was created. /// the b3Clock was created.

View File

@@ -13,8 +13,8 @@ public:
~b3Clock(); ~b3Clock();
/// Resets the initial reference time. /// Resets the initial reference time. If zeroReference is true, will set reference to absolute 0.
void reset(); void reset(bool zeroReference=false);
/// Returns the time in ms since the last call to reset or since /// Returns the time in ms since the last call to reset or since
/// the b3Clock was created. /// the b3Clock was created.