#include "Time.hpp" #include "Common/Casts.hpp" #include #include namespace MC { void Time::start_frame() { m_current_frame_start = now(); } void Time::end_frame() { auto frame_end = now(); m_delta = TO(Real, frame_end - m_current_frame_start) / 1000.0; m_delta = std::clamp(m_delta, delta_min, delta_max); m_total_frames++; } U64 Time::total_frames() const { return m_total_frames; } Time::Tick Time::tick() const { return total_frames(); } Real Time::delta() const { return m_delta; } Time::Timestamp Time::frame_start() const { return m_current_frame_start; } Time::Timestamp Time::now() { auto time = std::chrono::system_clock::now().time_since_epoch(); auto ms = std::chrono::duration_cast(time); return ms.count(); } }