M4: Stage.FixedUpdate + Time's fixed-step accumulator
Both were explicitly deferred to M4 by ITime and Stage's own doc comments back when they were written: a FixedUpdate stage with no real accumulator behind it would be actively misleading, and building the accumulator with no physics system to test it against would be untested speculative machinery. engine.physics (next) is the real consumer. Time.ConsumeFixedSteps accumulates DeltaTime and hands back how many FixedDeltaTime-sized (1/50s) steps it can pay for, capped at 5 per frame so a real stall becomes visible lag instead of a catch-up burst of physics steps. Engine.Host calls it once per frame in both the headless and windowed loops, running Stage.FixedUpdate that many times before Stage.Update — gated by IPlayModeController.IsPlaying the same way Update already is, and only accumulating time while actually playing, so entering Play doesn't open with a burst of steps for however long Edit mode had been sitting idle. 3 new tests on the accumulator itself (below-one-step, whole-steps-plus- remainder, the 5-step cap under a simulated stall). Full suite: 76 tests. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1qPfzq8TDCUMFMV3UwV5N
This commit is contained in:
@@ -3,16 +3,22 @@ namespace Engine.Kernel.Scheduling;
|
||||
/// <summary>
|
||||
/// Fixed, kernel-defined, not plugin-extensible — see "Frame stages" in
|
||||
/// docs/kernel-contract.md §8. <see cref="Present"/> is the second addition
|
||||
/// to the original {Update, Render} set (after FixedUpdate was scoped for
|
||||
/// M4), added for M3's editor: engine.render splits its old single
|
||||
/// Clear+Draw+SwapBuffers system into a Render-stage draw and a
|
||||
/// Present-stage swap specifically so engine.editor's ImGui overlay — which
|
||||
/// has to run after the scene is drawn but before the buffers swap — has
|
||||
/// somewhere to register that isn't a race against load order. Not a stage
|
||||
/// added speculatively: SwapBuffers already needed to move somewhere real.
|
||||
/// to the original {Update, Render} set, added for M3's editor: engine.
|
||||
/// render splits its old single Clear+Draw+SwapBuffers system into a
|
||||
/// Render-stage draw and a Present-stage swap specifically so engine.
|
||||
/// editor's ImGui overlay — which has to run after the scene is drawn but
|
||||
/// before the buffers swap — has somewhere to register that isn't a race
|
||||
/// against load order. <see cref="FixedUpdate"/> is the third, arriving
|
||||
/// with M4 exactly as ITime's own doc comment said it would: engine.physics
|
||||
/// steps Box3D here, at ITime.FixedDeltaTime's fixed rate, run zero-or-more
|
||||
/// times per frame by the accumulator Engine.Host drives — see
|
||||
/// Time.ConsumeFixedSteps. Runs before Update each frame it fires, so
|
||||
/// gameplay code reading a Rigidbody's position in Update sees this frame's
|
||||
/// physics result, not last frame's.
|
||||
/// </summary>
|
||||
public enum Stage
|
||||
{
|
||||
FixedUpdate,
|
||||
Update,
|
||||
Render,
|
||||
Present,
|
||||
|
||||
Reference in New Issue
Block a user