pub struct FixedTimestepStage { /* private fields */ }
Expand description

A Stage that runs a number of child stages with a fixed timestep

You can set the timestep duration. Every frame update, the time delta will be accumulated, and the child stages will run when it goes over the timestep threshold. If multiple timesteps have been accumulated, the child stages will be run multiple times.

You can add multiple child stages, allowing you to use Commands in your fixed timestep systems, and have their effects applied.

A good place to add the FixedTimestepStage is usually before CoreStage::Update.

Implementations

Helper to create a FixedTimestepStage with a single child stage

Create a new empty FixedTimestepStage with no child stages

Add a child stage

Builder method for adding a child stage

Enable EXPERIMENTAL “rate locking” algorithm

The idea is to detect if the fixed timestep rate is “close enough” to the actual update rate, and if yes, stop accumulating delta time, to run cleanly without hickups/jitter (at the real update rate, instead of the set timestep duration).

For example, if you set a timestep of 1.0/60.0 seconds, and run with vsync on a typical 59.97Hz monitor, you might prefer to just get one fixed update per frame anyway, instead of occasional hickups/jitter due to the subtle mismatch between the fixed timestep and the real rate.

The algorithm works as follows: count how many timesteps get executed each frame, and if the number doesn’t change for n_frames consecutive frames, enter “locked mode”. While in locked mode, reset the accumulator to half the step duration at the start of each execution. If, at any time, there is a frame that causes the accumulator to deviate by more than exit_deviation timestep durations, leave “locked mode”.

Reasonable parameters: n_frames: 5 to 15, exit_deviation: 0.05 to 0.1.

Builder-style method for [set_rate_lock]

Trait Implementations

Runs the stage; this happens once per update. Implementors must initialize all of their state and systems before running the first time. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more