Skip to main content

Eval

Trait Eval 

Source
pub trait Eval {
    type Output;

    // Provided methods
    fn eval_alpha(&self, _alpha: f64) -> Self::Output { ... }
    fn sample(&self, time: &SegmentTime) -> Self::Output { ... }
    fn reset(&mut self) { ... }
    fn step(&mut self, _time: &SegmentTime) { ... }
    fn apply_to(self, item: &mut Self::Output) -> Self
       where Self: Sized { ... }
    fn apply_alpha_to(self, item: &mut Self::Output, alpha: f64) -> Self
       where Self: Sized { ... }
}
Expand description

A normalized animation evaluator.

Functional (closed-form) segments implement Eval::eval_alpha; the other methods default appropriately. Iterative (stateful) segments implement Eval::sample/Eval::reset/Eval::step instead — eval_alpha has no closed form and its default panics if called.

Required Associated Types§

Source

type Output

Value produced by this evaluator.

Provided Methods§

Source

fn eval_alpha(&self, _alpha: f64) -> Self::Output

Evaluate the animation at a normalized progress in [0, 1]. Functional segments implement this; iterative segments have no closed form and the default panics (the runtime drives them via sample).

Source

fn sample(&self, time: &SegmentTime) -> Self::Output

Sample the current state at the given time context. Functional default = eval_alpha(time.alpha); iterative segments implement this to return their current state.

Source

fn reset(&mut self)

Reset to the segment’s initial state (deterministic contract: no wall clock, no unseeded RNG). No-op by default.

Source

fn step(&mut self, _time: &SegmentTime)

Advance one logic step (or substep); time.local_delta_secs is the integration step. No-op by default (functional segments are stepped as no-ops for free; sampling is unaffected).

Source

fn apply_to(self, item: &mut Self::Output) -> Self
where Self: Sized,

Apply the final state and return this evaluator.

Source

fn apply_alpha_to(self, item: &mut Self::Output, alpha: f64) -> Self
where Self: Sized,

Apply a sampled state and return this evaluator.

Implementors§

Source§

impl<T, F> Eval for F
where F: Fn(f64) -> T,

Source§

impl<T: Clone> Eval for Static<T>