/** * Checks whether the specified duration (dt) has passed since the last * update. If yes, it updates the time stamp. * @param now Current time * @param dt The timestep in seconds * @return */ bool CheckAdvance(const fixed now, const fixed dt) { if (CheckReverse(now)) return false; if (now >= last + dt) { Update(now); return true; } else return false; }
/** * Checks whether the specified duration (dt) has passed since the last * update. If yes, it updates the time stamp. * @param now Current time * @param dt The timestep in seconds * @return */ bool CheckAdvance(const double now, const std::chrono::steady_clock::duration dt) noexcept { if (CheckReverse(now)) return false; if (now >= last + std::chrono::duration_cast<std::chrono::duration<double>>(dt).count()) { Update(now); return true; } else return false; }
fixed DeltaAdvance(const fixed now) { if (CheckReverse(now)) return fixed_minus_one; // check if time has advanced past dt if (now - last >= dt) { fixed dt = now - last; Update(now); return dt; } else { return fixed_zero; } }