示例#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;
                }
            }
示例#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;
                }
            }
示例#3
0
                public static void Create(Node node)
                {
                    var component = new AnimationsStatesComponent {
                        animationsStates = new AnimationState[node.Animations.Count]
                    };

                    node.Components.Add(component);
                    var i = 0;

                    foreach (var animation in node.Animations)
                    {
                        var state = new AnimationState {
                            IsRunning = animation.IsRunning,
                            Time      = animation.Time
                        };
                        component.animationsStates[i] = state;
                        i++;
                    }

                    foreach (var child in node.Nodes)
                    {
                        Create(child);
                    }
                }