protected virtual void ProcessMarker(Animation animation, Marker marker, double previousTime, double currentTime) { if ((animation.OwnerNode.TangerineFlags & TangerineFlags.IgnoreMarkers) != 0) { ApplyAnimatorsAndExecuteTriggers(animation, previousTime, animation.Time, executeTriggersAtCurrentTime: false); return; } switch (marker.Action) { case MarkerAction.Jump: var gotoMarker = animation.Markers.TryFind(marker.JumpTo); if (gotoMarker != null && gotoMarker != marker) { var delta = animation.Time - AnimationUtils.FramesToSeconds(animation.Frame); animation.TimeInternal = gotoMarker.Time; if (JumpAffectsRunningMarkerId) { animation.RunningMarkerId = gotoMarker.Id; } AdvanceAnimation(animation, delta); } break; case MarkerAction.Stop: animation.TimeInternal = AnimationUtils.FramesToSeconds(marker.Frame); ApplyAnimatorsAndExecuteTriggers(animation, previousTime, animation.Time, executeTriggersAtCurrentTime: true); animation.IsRunning = false; break; case MarkerAction.Play: ApplyAnimatorsAndExecuteTriggers(animation, previousTime, currentTime, executeTriggersAtCurrentTime: false); break; } marker.CustomAction?.Invoke(); }
private List <MorphingInterval> GetMorphingIntervals(Node node) { var allFrames = new SortedSet <int>(); var leapFrames = new SortedSet <int>(); EnumerateKeyFrames(allFrames, leapFrames, node); var result = new List <MorphingInterval>(); var interval = new MorphingInterval(); foreach (var frame in allFrames) { var time = AnimationUtils.FramesToSeconds(frame); if (leapFrames.Contains(frame)) { if (interval.Timestamps.Count > 0) { interval.Timestamps.Add(time - 1); result.Add(interval); interval = new MorphingInterval(); } } interval.Timestamps.Add(time); } if (interval.Timestamps.Count > 0) { result.Add(interval); } if (result.Count == 0) { result.Add(new MorphingInterval { Timestamps = { 0, 0 } }); } return(result); }
public override bool TryRunAnimation(Animation animation, string markerId, double animationTimeCorrection = 0) { var frame = 0; if (markerId != null) { var marker = animation.Markers.TryFind(markerId); if (marker == null) { return(false); } frame = marker.Frame; } // Easings may give huge animationTimeCorrection values, clamp it. animationTimeCorrection = Mathf.Clamp(animationTimeCorrection, -AnimationUtils.SecondsPerFrame + AnimationUtils.Threshold, 0); animation.Time = AnimationUtils.FramesToSeconds(frame) + animationTimeCorrection; animation.RunningMarkerId = markerId; animation.IsRunning = true; return(true); }
public BlendingOption(int frames) : this(AnimationUtils.FramesToSeconds(frames)) { }