AnimationCurve

Trait AnimationCurve 

Source
pub trait AnimationCurve:
    Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn clone_value(&self) -> Box<dyn AnimationCurve>;
    fn domain(&self) -> Interval;
    fn evaluator_id(&self) -> EvaluatorId<'_>;
    fn create_evaluator(&self) -> Box<dyn AnimationCurveEvaluator>;
    fn apply(
        &self,
        curve_evaluator: &mut (dyn AnimationCurveEvaluator + 'static),
        t: f32,
        weight: f32,
        graph_node: NodeIndex,
    ) -> Result<(), AnimationEvaluationError>;
}
Expand description

A low-level trait that provides control over how curves are actually applied to entities by the animation system.

Typically, this will not need to be implemented manually, since it is automatically implemented by AnimatableCurve and other curves used by the animation system (e.g. those that animate parts of transforms or morph weights). However, this can be implemented manually when AnimatableCurve is not sufficiently expressive.

In many respects, this behaves like a type-erased form of Curve, where the output type of the curve is remembered only in the components that are mutated in the implementation of apply.

Required Methods§

Source

fn clone_value(&self) -> Box<dyn AnimationCurve>

Returns a boxed clone of this value.

Source

fn domain(&self) -> Interval

The range of times for which this animation is defined.

Source

fn evaluator_id(&self) -> EvaluatorId<'_>

Returns the type ID of the AnimationCurveEvaluator.

This must match the type returned by Self::create_evaluator. It must be a single type that doesn’t depend on the type of the curve.

Source

fn create_evaluator(&self) -> Box<dyn AnimationCurveEvaluator>

Returns a newly-instantiated AnimationCurveEvaluator for use with this curve.

All curve types must return the same type of AnimationCurveEvaluator. The returned value must match the type returned by Self::evaluator_id.

Source

fn apply( &self, curve_evaluator: &mut (dyn AnimationCurveEvaluator + 'static), t: f32, weight: f32, graph_node: NodeIndex, ) -> Result<(), AnimationEvaluationError>

Samples the curve at the given time t, and pushes the sampled value onto the evaluation stack of the curve_evaluator.

The curve_evaluator parameter points to the value returned by Self::create_evaluator, upcast to an &mut dyn AnimationCurveEvaluator. Typically, implementations of Self::apply will want to downcast the curve_evaluator parameter to the concrete type Self::evaluator_id in order to push values of the appropriate type onto its evaluation stack.

Be sure not to confuse the t and weight values. The former determines the position at which the curve is sampled, while weight ultimately determines how much the stack values will be blended together (see the definition of AnimationCurveEvaluator::blend).

Implementors§