Exemple #1
0
            internal static void SetCurrentFrameToNode(int frameIndex, Node node, bool animationMode, bool isForced)
            {
                Audio.GloballyEnable = false;
                try {
                    var doc = Current;
                    if (animationMode && (doc.AnimationFrame != frameIndex || isForced))
                    {
                        node.SetTangerineFlag(TangerineFlags.IgnoreMarkers, true);
                        var cacheFrame = node.Components.Get <AnimationsStatesComponent>()?.Column;
                        if (cacheFrame.HasValue && (cacheFrame.Value > frameIndex ||
                                                    frameIndex > cacheFrame.Value + OptimalRollbackForCacheAnimationsStates * 2))
                        {
                            AnimationsStatesComponent.Remove(node);
                            cacheFrame = null;
                        }
                        if (!cacheFrame.HasValue)
                        {
                            StopAnimationRecursive(node);
                            SetTimeRecursive(node, 0);
                        }
                        else
                        {
                            AnimationsStatesComponent.Restore(node);
                        }
                        ClearParticlesRecursive(doc.RootNode);
                        node.IsRunning = true;

                        if (CacheAnimationsStates && !cacheFrame.HasValue)
                        {
                            cacheFrame = frameIndex - OptimalRollbackForCacheAnimationsStates;
                            if (cacheFrame.Value > 0)
                            {
                                FastForwardToFrame(node, cacheFrame.Value);
                                AnimationsStatesComponent.Create(node);
                            }
                        }
                        FastForwardToFrame(node, frameIndex);
                        StopAnimationRecursive(node);
                        node.SetTangerineFlag(TangerineFlags.IgnoreMarkers, false);

                        // Force update to reset Animation.NextMarkerOrTriggerTime for parents.
                        doc.Container.AnimationFrame = doc.Container.AnimationFrame;
                        doc.RootNode.Update(0);
                    }
                    else
                    {
                        node.AnimationFrame = frameIndex;
                        node.Update(0);
                        ClearParticlesRecursive(node);
                    }
                } finally {
                    Audio.GloballyEnable = true;
                }
            }
Exemple #2
0
            void SetColumn(int value, Node node)
            {
                Audio.GloballyEnable = false;
                try {
                    var doc = Document.Current;
                    if (TimelineUserPreferences.Instance.AnimationMode && doc.AnimationFrame != value)
                    {
                        node.SetTangerineFlag(TangerineFlags.IgnoreMarkers, true);
                        var cacheFrame = node.Components.Get <AnimationsStatesComponent>()?.Column;
                        if (cacheFrame.HasValue && (cacheFrame.Value > value || value > cacheFrame.Value + OptimalRollbackForCacheAnimationsStates * 2))
                        {
                            AnimationsStatesComponent.Remove(node);
                            cacheFrame = null;
                        }
                        if (!cacheFrame.HasValue)
                        {
                            StopAnimationRecursive(node);
                            SetTimeRecursive(node, 0);
                        }
                        else
                        {
                            AnimationsStatesComponent.Restore(node);
                        }
                        ClearParticlesRecursive(doc.RootNode);
                        node.IsRunning = true;

                        if (CacheAnimationsStates && !cacheFrame.HasValue)
                        {
                            cacheFrame = value - OptimalRollbackForCacheAnimationsStates;
                            if (cacheFrame.Value > 0)
                            {
                                FastForwardToFrame(node, cacheFrame.Value);
                                AnimationsStatesComponent.Create(node, cacheFrame.Value);
                            }
                        }
                        FastForwardToFrame(node, value);
                        StopAnimationRecursive(node);
                        node.SetTangerineFlag(TangerineFlags.IgnoreMarkers, false);
                    }
                    else
                    {
                        node.AnimationFrame = value;
                        node.Update(0);
                        ClearParticlesRecursive(node);
                    }
                    Timeline.Instance.EnsureColumnVisible(value);
                } finally {
                    Audio.GloballyEnable = true;
                }
            }