Struct iyes_loopless::fixedtimestep::FixedTimestepStage
source · [−]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
sourceimpl FixedTimestepStage
impl FixedTimestepStage
sourcepub fn from_stage<S: Stage>(timestep: Duration, stage: S) -> Self
pub fn from_stage<S: Stage>(timestep: Duration, stage: S) -> Self
Helper to create a FixedTimestepStage with a single child stage
sourcepub fn new(timestep: Duration) -> Self
pub fn new(timestep: Duration) -> Self
Create a new empty FixedTimestepStage with no child stages
sourcepub fn with_stage<S: Stage>(self, stage: S) -> Self
pub fn with_stage<S: Stage>(self, stage: S) -> Self
Builder method for adding a child stage
sourcepub fn set_rate_lock(&mut self, n_frames: u32, exit_deviation: f32)
pub fn set_rate_lock(&mut self, n_frames: u32, exit_deviation: f32)
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.
sourcepub fn with_rate_lock(self, n_frames: u32, exit_deviation: f32) -> Self
pub fn with_rate_lock(self, n_frames: u32, exit_deviation: f32) -> Self
Builder-style method for [set_rate_lock]
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for FixedTimestepStage
impl Send for FixedTimestepStage
impl Sync for FixedTimestepStage
impl Unpin for FixedTimestepStage
impl !UnwindSafe for FixedTimestepStage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more