fn include_animation(
        animation: Animation,
        sheet: &mut HashMap<String, AnimationPhase>,
        messages: &mut Vec<(Scalar, String)>,
        mut time: Scalar,
    ) -> (Scalar, bool) {
        match animation {
            Animation::Value(value) => {
                let duration = value.duration.max(0.0);
                let phase = AnimationPhase {
                    start: time,
                    duration,
                    cached_time: 0.0,
                    cached_progress: 0.0,
                };
                sheet.insert(value.name, phase);
                (time + duration, false)
            }
            Animation::Sequence(anims) => {
                for anim in anims {
                    time = Self::include_animation(anim, sheet, messages, time).0;
                }
                (time, false)
            }
            Animation::Parallel(anims) => {
                let mut result = time;
                for anim in anims {
                    result = Self::include_animation(anim, sheet, messages, time)
                        .0
                        .max(result);
                }
                (result, false)
            }
            Animation::Looped(anim) => {
                let looped = sheet.is_empty();
                time = Self::include_animation(*anim, sheet, messages, time).0;
                (time, looped)
            }
            Animation::TimeShift(v) => ((time - v).max(0.0), false),
            Animation::Message(message) => {
                messages.push((time, message));
                (time, false)
            }
        }
    }
// Add an animation to this [`AnimatorState`] recursively
Add an animation to this [`AnimatorState`] recursively
Add an animation to this [ ` AnimatorState ` ] recursively
fn include_animation(
        animation: Animation,
        sheet: &mut HashMap<String, AnimationPhase>,
        messages: &mut Vec<(Scalar, String)>,
        mut time: Scalar,
    ) -> (Scalar, bool) {
        match animation {
            Animation::Value(value) => {
                let duration = value.duration.max(0.0);
                let phase = AnimationPhase {
                    start: time,
                    duration,
                    cached_time: 0.0,
                    cached_progress: 0.0,
                };
                sheet.insert(value.name, phase);
                (time + duration, false)
            }
            Animation::Sequence(anims) => {
                for anim in anims {
                    time = Self::include_animation(anim, sheet, messages, time).0;
                }
                (time, false)
            }
            Animation::Parallel(anims) => {
                let mut result = time;
                for anim in anims {
                    result = Self::include_animation(anim, sheet, messages, time)
                        .0
                        .max(result);
                }
                (result, false)
            }
            Animation::Looped(anim) => {
                let looped = sheet.is_empty();
                time = Self::include_animation(*anim, sheet, messages, time).0;
                (time, looped)
            }
            Animation::TimeShift(v) => ((time - v).max(0.0), false),
            Animation::Message(message) => {
                messages.push((time, message));
                (time, false)
            }
        }
    }
fn include_animation ( animation : Animation , sheet : & mut HashMap < String , AnimationPhase > , messages : & mut Vec < ( Scalar , String ) > , mut time : Scalar , ) -> ( Scalar , bool ) { match animation { Animation :: Value ( value ) => { let duration = value . duration . max ( 0.0 ) ; let phase = AnimationPhase { start : time , duration , cached_time : 0.0 , cached_progress : 0.0 , } ; sheet . insert ( value . name , phase ) ; ( time + duration , false ) } Animation :: Sequence ( anims ) => { for anim in anims { time = Self :: include_animation ( anim , sheet , messages , time ) . 0 ; } ( time , false ) } Animation :: Parallel ( anims ) => { let mut result = time ; for anim in anims { result = Self :: include_animation ( anim , sheet , messages , time ) . 0 . max ( result ) ; } ( result , false ) } Animation :: Looped ( anim ) => { let looped = sheet . is_empty ( ) ; time = Self :: include_animation ( * anim , sheet , messages , time ) . 0 ; ( time , looped ) } Animation :: TimeShift ( v ) => ( ( time - v ) . max ( 0.0 ) , false ) , Animation :: Message ( message ) => { messages . push ( ( time , message ) ) ; ( time , false ) } } }
Add an animation to this [`AnimatorState`] recursively
Add an animation to this [ ` AnimatorState ` ] recursively
animation
Animation
sheet
&mut HashMap<String, AnimationPhase>
messages
&mut Vec<(Scalar, String)>
time
Scalar
animation
Animation
sheet
&mut HashMap<String, AnimationPhase>
messages
&mut Vec<(Scalar, String)>
time
Scalar