From 48422e313b31b79d76dd8f027b4d934994168859 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 26 Apr 2026 13:06:44 -0700 Subject: Test for catch-up. Document --- simloop/include/simloop.h | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'simloop/include/simloop.h') diff --git a/simloop/include/simloop.h b/simloop/include/simloop.h index 7774c35..4e3ed20 100644 --- a/simloop/include/simloop.h +++ b/simloop/include/simloop.h @@ -1,49 +1,3 @@ -/* Simulation loop module. - * - * This implements a simulation loop but in a way that the client retains - * control flow. The client steps the loop and then checks whether the - * simulation must be updated and/or the result rendered. - * - * The simulation is updated at a fixed time step given a desired frame rate. - * Rendering frame rate can likewise be capped or be unlimited. - * In any case, an interpolation factor is computed for smooth animation between - * updates. - * The implementation also guarantees that the same frame is not rendered twice - * if time does not advance. - * - * Generally, the simulation's update logic should be able to keep up with the - * requested frame rate; it is the application's responsibility to ensure this. - * Should the update logic not be able to keep up, then the loop requests a - * single update per iteration, effectively "degrading" to match the update - * logic frame rate, giving the update logic a chance to catch up with - * subsequent loop iterations. - * - * Under a variable time delta, the loop could simply update the simulation - * with a large delta that puts the simulation back into the current clock - * time. Under a fixed time delta this isn't possible, and we seem to have two - * choices instead: - * - * a) Queue as many updates as necessary to bring the simulation back to the - * current clock time (time_difference / fixed_delta). - * - * b) Queue a single update. - * - * The issue with (a) is that, if the simulation is never able to catch up, then - * the number of requested updates at every loop iteration diverges and - * eventually the simulation appears to freeze. Example: - * - * desired delta = 10ms (100 fps) - * actual delta = 20ms ( 50 fps) - * --------------------------- - * iter, sim time, clock time - * --------------------------- - * 0, 0, 0, initial state - * 1, 0, 10, queue 1 update - * 2, 10, 30, queue (30-10)/10 = 2 updates - * 3, 30, 70, queue (70-30)/10 = 4 updates - * 4, 70, 150, queue (150-70)/10 = 8 updates - * ... - */ #pragma once #include -- cgit v1.2.3