Skip to main content

IterativeEval

Trait IterativeEval 

Source
pub trait IterativeEval {
    type Output;

    // Required method
    fn step(&self, output: &mut Self::Output, alpha: f64, delta_alpha: f64);
}
Expand description

The capability of an iterative, stateful evaluation.

This is what iterative animation types implement: particles, springs, physics simulations, and anything without a closed form. The state is owned and advanced by the Iterative adapter, and step receives it as a mutable reference.

Only one method, no defaults. There is no reset to forget or get wrong — the adapter restores the stored initial state itself. Physics parameters, palettes, and logical durations belong on self or in local variables captured by a closure (not in global constants); everything mutable must live in the state value, so a reset restores it all.

step receives the current progress alpha and the segment’s own uniform progress step delta_alpha (= sim_step = 1 / N). These are dimensionless progress, independent of rate shaping and placement; the segment’s content is a pure function of progress. To recover physical seconds, scale by the segment’s own logical duration:

ⓘ
fn step(&self, state: &mut NBodyState, _alpha: f64, delta_alpha: f64) {
    let dt = self.sim_secs * delta_alpha; // physical seconds
    state.integrate(dt);
}

Segments that genuinely need scene-clock-shaped time must be authored at the top level, where the author knows the placement.

Required Associated Types§

Source

type Output

State produced and advanced by this evaluator.

Required Methods§

Source

fn step(&self, output: &mut Self::Output, alpha: f64, delta_alpha: f64)

Advance the state by one progress step.

alpha is the current progress, delta_alpha the segment’s uniform step (both dimensionless progress). The step size is declared on the Iterative adapter with Iterative::with_steps: delta_alpha = 1 / N for with_steps(N), or the default 1 / 120 when it is not called.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S, F> IterativeEval for IterativeFn<S, F>
where F: Fn(&mut S, f64, f64),