Class FixedTimestep<T extends Time>

java.lang.Object
dev.engine.core.module.FixedTimestep<T>
Type Parameters:
T - the update context type passed to modules
All Implemented Interfaces:
UpdateStrategy<T>

public class FixedTimestep<T extends Time> extends Object implements UpdateStrategy<T>
Accumulator-based fixed timestep UpdateStrategy.

Accumulates elapsed time and fires a fixed number of update steps per tick, each step using a constant delta-time value derived from the target frequency. Excess accumulated time beyond the cap is discarded to prevent a spiral of death.

  • Constructor Details

    • FixedTimestep

      public FixedTimestep(double targetHz, BiFunction<Long,Double,T> contextFactory, int maxStepsPerTick)
    • FixedTimestep

      public FixedTimestep(double targetHz, BiFunction<Long,Double,T> contextFactory)
  • Method Details

    • advance

      public void advance(double elapsedSeconds, Consumer<T> onUpdate)
      Description copied from interface: UpdateStrategy
      Advances time by the given elapsed seconds and invokes onUpdate for each computed update step.
      Specified by:
      advance in interface UpdateStrategy<T extends Time>
      Parameters:
      elapsedSeconds - real wall-clock time elapsed since last advance
      onUpdate - callback invoked with the context for each update step
    • getFixedDt

      public double getFixedDt()
    • getTargetHz

      public double getTargetHz()
    • getAccumulator

      public double getAccumulator()
    • getMaxStepsPerTick

      public int getMaxStepsPerTick()