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>
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 Summary
ConstructorsConstructorDescriptionFixedTimestep(double targetHz, BiFunction<Long, Double, T> contextFactory) FixedTimestep(double targetHz, BiFunction<Long, Double, T> contextFactory, int maxStepsPerTick) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdvances time by the given elapsed seconds and invokesonUpdatefor each computed update step.doubledoubleintdouble
-
Constructor Details
-
FixedTimestep
public FixedTimestep(double targetHz, BiFunction<Long, Double, T> contextFactory, int maxStepsPerTick) -
FixedTimestep
-
-
Method Details
-
advance
Description copied from interface:UpdateStrategyAdvances time by the given elapsed seconds and invokesonUpdatefor each computed update step.- Specified by:
advancein interfaceUpdateStrategy<T extends Time>- Parameters:
elapsedSeconds- real wall-clock time elapsed since last advanceonUpdate- 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()
-