This commit is contained in:
2025-10-27 11:53:12 +01:00
parent 231dcd4b3b
commit 5d8811026d
69 changed files with 899 additions and 888 deletions

View File

@@ -3,22 +3,22 @@
DeltaTimer::DeltaTimer() noexcept
: last_counter_(SDL_GetPerformanceCounter()),
perf_freq_(static_cast<double>(SDL_GetPerformanceFrequency())),
time_scale_(1.0f) {
time_scale_(1.0F) {
}
float DeltaTimer::tick() noexcept {
const Uint64 now = SDL_GetPerformanceCounter();
const Uint64 diff = (now > last_counter_) ? (now - last_counter_) : 0;
last_counter_ = now;
const double seconds = static_cast<double>(diff) / perf_freq_;
return static_cast<float>(seconds * static_cast<double>(time_scale_));
const Uint64 NOW = SDL_GetPerformanceCounter();
const Uint64 DIFF = (NOW > last_counter_) ? (NOW - last_counter_) : 0;
last_counter_ = NOW;
const double SECONDS = static_cast<double>(DIFF) / perf_freq_;
return static_cast<float>(SECONDS * static_cast<double>(time_scale_));
}
float DeltaTimer::peek() const noexcept {
const Uint64 now = SDL_GetPerformanceCounter();
const Uint64 diff = (now > last_counter_) ? (now - last_counter_) : 0;
const double seconds = static_cast<double>(diff) / perf_freq_;
return static_cast<float>(seconds * static_cast<double>(time_scale_));
const Uint64 NOW = SDL_GetPerformanceCounter();
const Uint64 DIFF = (NOW > last_counter_) ? (NOW - last_counter_) : 0;
const double SECONDS = static_cast<double>(DIFF) / perf_freq_;
return static_cast<float>(SECONDS * static_cast<double>(time_scale_));
}
void DeltaTimer::reset(Uint64 counter) noexcept {
@@ -30,7 +30,7 @@ void DeltaTimer::reset(Uint64 counter) noexcept {
}
void DeltaTimer::setTimeScale(float scale) noexcept {
time_scale_ = std::max(scale, 0.0f);
time_scale_ = std::max(scale, 0.0F);
}
float DeltaTimer::getTimeScale() const noexcept {