public void SetBroken(object _keysToSet)
        {
            List <ChangedCurve>  list  = new List <ChangedCurve>();
            List <KeyIdentifier> list2 = (List <KeyIdentifier>)_keysToSet;

            foreach (KeyIdentifier current in list2)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                AnimationUtility.SetKeyBroken(ref keyframe, true);
                if (AnimationUtility.GetKeyRightTangentMode(keyframe) == AnimationUtility.TangentMode.ClampedAuto || AnimationUtility.GetKeyRightTangentMode(keyframe) == AnimationUtility.TangentMode.Auto)
                {
                    AnimationUtility.SetKeyRightTangentMode(ref keyframe, AnimationUtility.TangentMode.Free);
                }
                if (AnimationUtility.GetKeyLeftTangentMode(keyframe) == AnimationUtility.TangentMode.ClampedAuto || AnimationUtility.GetKeyLeftTangentMode(keyframe) == AnimationUtility.TangentMode.Auto)
                {
                    AnimationUtility.SetKeyLeftTangentMode(ref keyframe, AnimationUtility.TangentMode.Free);
                }
                curve.MoveKey(current.key, keyframe);
                AnimationUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.curveId, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
            }
            this.updater.UpdateCurves(list, "Set Tangents");
        }
        public void SetBoth(AnimationUtility.TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> list = new List <ChangedCurve>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                AnimationUtility.SetKeyBroken(ref keyframe, false);
                AnimationUtility.SetKeyRightTangentMode(ref keyframe, mode);
                AnimationUtility.SetKeyLeftTangentMode(ref keyframe, mode);
                if (mode == AnimationUtility.TangentMode.Free)
                {
                    float num = CurveUtility.CalculateSmoothTangent(keyframe);
                    keyframe.inTangent  = num;
                    keyframe.outTangent = num;
                }
                curve.MoveKey(current.key, keyframe);
                AnimationUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.curveId, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
            }
            this.updater.UpdateCurves(list, "Set Tangents");
        }
Exemplo n.º 3
0
        public void Flatten(List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> curve1   = new List <ChangedCurve>();
            List <int>          curveIds = new List <int>();

            using (List <KeyIdentifier> .Enumerator enumerator = keysToSet.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyIdentifier  current  = enumerator.Current;
                    AnimationCurve curve2   = current.curve;
                    Keyframe       keyframe = current.keyframe;
                    keyframe.inTangent  = 0.0f;
                    keyframe.outTangent = 0.0f;
                    curve2.MoveKey(current.key, keyframe);
                    CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
                    ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
                    if (!curve1.Contains(changedCurve))
                    {
                        curve1.Add(changedCurve);
                    }
                    curveIds.Add(current.curveId);
                }
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(curve1, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(curveIds, "Set Tangents");
            }
        }
        public void SetTangent(int leftRight, TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> changedCurves = new List <ChangedCurve>();

            foreach (KeyIdentifier keyToSet in keysToSet)
            {
                AnimationCurve animationCurve = keyToSet.curve;
                Keyframe       key            = keyToSet.keyframe;
                AnimationUtility.SetKeyBroken(ref key, true);
                if (leftRight == 2)
                {
                    AnimationUtility.SetKeyLeftTangentMode(ref key, mode);
                    AnimationUtility.SetKeyRightTangentMode(ref key, mode);
                }
                else
                {
                    if (leftRight == 0)
                    {
                        AnimationUtility.SetKeyLeftTangentMode(ref key, mode);

                        // Make sure other tangent is handled correctly
                        if (AnimationUtility.GetKeyRightTangentMode(key) == TangentMode.ClampedAuto || AnimationUtility.GetKeyRightTangentMode(key) == TangentMode.Auto)
                        {
                            AnimationUtility.SetKeyRightTangentMode(ref key, TangentMode.Free);
                        }
                    }
                    else //if (leftRight == 1)
                    {
                        AnimationUtility.SetKeyRightTangentMode(ref key, mode);

                        // Make sure other tangent is handled correctly
                        if (AnimationUtility.GetKeyLeftTangentMode(key) == TangentMode.ClampedAuto || AnimationUtility.GetKeyLeftTangentMode(key) == TangentMode.Auto)
                        {
                            AnimationUtility.SetKeyLeftTangentMode(ref key, TangentMode.Free);
                        }
                    }
                }

                if (mode == TangentMode.Constant && (leftRight == 0 || leftRight == 2))
                {
                    key.inTangent = Mathf.Infinity;
                }
                if (mode == TangentMode.Constant && (leftRight == 1 || leftRight == 2))
                {
                    key.outTangent = Mathf.Infinity;
                }

                animationCurve.MoveKey(keyToSet.key, key);
                AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyToSet.key);
                // Debug.Log ("Before " + DebKey (key) + " after: " + DebKey (animationCurve[keyToSet.key]));

                ChangedCurve changedCurve = new ChangedCurve(animationCurve, keyToSet.curveId, keyToSet.binding);
                if (!changedCurves.Contains(changedCurve))
                {
                    changedCurves.Add(changedCurve);
                }
            }

            updater.UpdateCurves(changedCurves, "Set Tangents");
        }
        public void SetBroken(object _keysToSet)
        {
            List <ChangedCurve>  changedCurves = new List <ChangedCurve>();
            List <KeyIdentifier> keysToSet     = (List <KeyIdentifier>)_keysToSet;

            foreach (KeyIdentifier keyToSet in keysToSet)
            {
                AnimationCurve animationCurve = keyToSet.curve;
                Keyframe       key            = keyToSet.keyframe;
                AnimationUtility.SetKeyBroken(ref key, true);
                if (AnimationUtility.GetKeyRightTangentMode(key) == TangentMode.ClampedAuto || AnimationUtility.GetKeyRightTangentMode(key) == TangentMode.Auto)
                {
                    AnimationUtility.SetKeyRightTangentMode(ref key, TangentMode.Free);
                }
                if (AnimationUtility.GetKeyLeftTangentMode(key) == TangentMode.ClampedAuto || AnimationUtility.GetKeyLeftTangentMode(key) == TangentMode.Auto)
                {
                    AnimationUtility.SetKeyLeftTangentMode(ref key, TangentMode.Free);
                }

                animationCurve.MoveKey(keyToSet.key, key);
                AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyToSet.key);

                ChangedCurve changedCurve = new ChangedCurve(animationCurve, keyToSet.curveId, keyToSet.binding);
                if (!changedCurves.Contains(changedCurve))
                {
                    changedCurves.Add(changedCurve);
                }
            }

            updater.UpdateCurves(changedCurves, "Set Tangents");
        }
Exemplo n.º 6
0
        public void Flatten(List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> list  = new List <ChangedCurve>();
            List <int>          list2 = new List <int>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                keyframe.inTangent  = 0f;
                keyframe.outTangent = 0f;
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
                list2.Add(current.curveId);
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(list, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(list2, "Set Tangents");
            }
        }
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> changedCurves = new List <ChangedCurve>();

            foreach (KeyIdentifier keyToSet in keysToSet)
            {
                AnimationCurve animationCurve = keyToSet.curve;
                Keyframe       key            = keyToSet.keyframe;
                AnimationUtility.SetKeyBroken(ref key, false);
                AnimationUtility.SetKeyRightTangentMode(ref key, mode);
                AnimationUtility.SetKeyLeftTangentMode(ref key, mode);

                // Smooth Tangents based on neighboring nodes
                // Note: not needed since the UpdateTangentsFromModeSurrounding call below will handle it
                //if (mode == TangentMode.ClampedAuto) animationCurve.SmoothTangents(keyToSet.key, 0.0F);
                // Smooth tangents based on existing tangents
                if (mode == TangentMode.Free)
                {
                    float slope = CurveUtility.CalculateSmoothTangent(key);
                    key.inTangent  = slope;
                    key.outTangent = slope;
                }
                animationCurve.MoveKey(keyToSet.key, key);
                AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyToSet.key);

                ChangedCurve changedCurve = new ChangedCurve(animationCurve, keyToSet.curveId, keyToSet.binding);
                if (!changedCurves.Contains(changedCurve))
                {
                    changedCurves.Add(changedCurve);
                }
            }

            updater.UpdateCurves(changedCurves, "Set Tangents");
        }
        public void ToggleWeighted(WeightedMode weightedMode, List <KeyIdentifier> keysToSet)
        {
            bool allWeighted = keysToSet.TrueForAll(key => (key.keyframe.weightedMode & weightedMode) == weightedMode);

            List <ChangedCurve> changedCurves = new List <ChangedCurve>();

            foreach (KeyIdentifier keyToSet in keysToSet)
            {
                AnimationCurve animationCurve = keyToSet.curve;
                Keyframe       key            = keyToSet.keyframe;

                bool weighted = (key.weightedMode & weightedMode) == weightedMode;
                if (weighted == allWeighted)
                {
                    WeightedMode lastWeightedMode = key.weightedMode;
                    key.weightedMode = weighted ? key.weightedMode & ~weightedMode : key.weightedMode | weightedMode;

                    if (key.weightedMode != WeightedMode.None)
                    {
                        TangentMode rightTangentMode = AnimationUtility.GetKeyRightTangentMode(key);
                        TangentMode leftTangentMode  = AnimationUtility.GetKeyLeftTangentMode(key);

                        if ((lastWeightedMode & WeightedMode.Out) == WeightedMode.None && (key.weightedMode & WeightedMode.Out) == WeightedMode.Out)
                        {
                            if (rightTangentMode == TangentMode.Linear || rightTangentMode == TangentMode.Constant)
                            {
                                AnimationUtility.SetKeyRightTangentMode(ref key, TangentMode.Free);
                            }
                            if (keyToSet.key < (animationCurve.length - 1))
                            {
                                key.outWeight = 1 / 3.0f;
                            }
                        }

                        if ((lastWeightedMode & WeightedMode.In) == WeightedMode.None && (key.weightedMode & WeightedMode.In) == WeightedMode.In)
                        {
                            if (leftTangentMode == TangentMode.Linear || leftTangentMode == TangentMode.Constant)
                            {
                                AnimationUtility.SetKeyLeftTangentMode(ref key, TangentMode.Free);
                            }
                            if (keyToSet.key > 0)
                            {
                                key.inWeight = 1 / 3.0f;
                            }
                        }
                    }

                    animationCurve.MoveKey(keyToSet.key, key);
                    AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyToSet.key);

                    ChangedCurve changedCurve = new ChangedCurve(animationCurve, keyToSet.curveId, keyToSet.binding);
                    if (!changedCurves.Contains(changedCurve))
                    {
                        changedCurves.Add(changedCurve);
                    }
                }
            }

            updater.UpdateCurves(changedCurves, "Toggle Weighted");
        }
Exemplo n.º 9
0
        public void SetTangent(int leftRight, TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <int>          curveIds = new List <int>();
            List <ChangedCurve> curve1   = new List <ChangedCurve>();

            using (List <KeyIdentifier> .Enumerator enumerator = keysToSet.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyIdentifier  current  = enumerator.Current;
                    AnimationCurve curve2   = current.curve;
                    Keyframe       keyframe = current.keyframe;
                    CurveUtility.SetKeyBroken(ref keyframe, true);
                    if (leftRight == 2)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                        CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                    }
                    else
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, leftRight, mode);
                        if (CurveUtility.GetKeyTangentMode(keyframe, 1 - leftRight) == TangentMode.Smooth)
                        {
                            CurveUtility.SetKeyTangentMode(ref keyframe, 1 - leftRight, TangentMode.Editable);
                        }
                    }
                    if (mode == TangentMode.Stepped && (leftRight == 0 || leftRight == 2))
                    {
                        keyframe.inTangent = float.PositiveInfinity;
                    }
                    if (mode == TangentMode.Stepped && (leftRight == 1 || leftRight == 2))
                    {
                        keyframe.outTangent = float.PositiveInfinity;
                    }
                    curve2.MoveKey(current.key, keyframe);
                    CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
                    ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
                    if (!curve1.Contains(changedCurve))
                    {
                        curve1.Add(changedCurve);
                    }
                    curveIds.Add(current.curveId);
                }
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(curve1, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(curveIds, "Set Tangents");
            }
        }
        public void ToggleWeighted(WeightedMode weightedMode, List <KeyIdentifier> keysToSet)
        {
            bool flag = keysToSet.TrueForAll((KeyIdentifier key) => (key.keyframe.weightedMode & weightedMode) == weightedMode);
            List <ChangedCurve> list = new List <ChangedCurve>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                bool           flag2    = (keyframe.weightedMode & weightedMode) == weightedMode;
                if (flag2 == flag)
                {
                    WeightedMode weightedMode2 = keyframe.weightedMode;
                    keyframe.weightedMode = ((!flag2) ? (keyframe.weightedMode | weightedMode) : (keyframe.weightedMode & ~weightedMode));
                    if (keyframe.weightedMode != WeightedMode.None)
                    {
                        AnimationUtility.TangentMode keyRightTangentMode = AnimationUtility.GetKeyRightTangentMode(keyframe);
                        AnimationUtility.TangentMode keyLeftTangentMode  = AnimationUtility.GetKeyLeftTangentMode(keyframe);
                        if ((weightedMode2 & WeightedMode.Out) == WeightedMode.None && (keyframe.weightedMode & WeightedMode.Out) == WeightedMode.Out)
                        {
                            if (keyRightTangentMode == AnimationUtility.TangentMode.Linear || keyRightTangentMode == AnimationUtility.TangentMode.Constant)
                            {
                                AnimationUtility.SetKeyRightTangentMode(ref keyframe, AnimationUtility.TangentMode.Free);
                            }
                            if (current.key < curve.length - 1)
                            {
                                keyframe.outWeight = 0.333333343f;
                            }
                        }
                        if ((weightedMode2 & WeightedMode.In) == WeightedMode.None && (keyframe.weightedMode & WeightedMode.In) == WeightedMode.In)
                        {
                            if (keyLeftTangentMode == AnimationUtility.TangentMode.Linear || keyLeftTangentMode == AnimationUtility.TangentMode.Constant)
                            {
                                AnimationUtility.SetKeyLeftTangentMode(ref keyframe, AnimationUtility.TangentMode.Free);
                            }
                            if (current.key > 0)
                            {
                                keyframe.inWeight = 0.333333343f;
                            }
                        }
                    }
                    curve.MoveKey(current.key, keyframe);
                    AnimationUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                    ChangedCurve item = new ChangedCurve(curve, current.curveId, current.binding);
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
            this.updater.UpdateCurves(list, "Toggle Weighted");
        }
Exemplo n.º 11
0
        public void SetTangent(int leftRight, TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <int>          list  = new List <int>();
            List <ChangedCurve> list2 = new List <ChangedCurve>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, true);
                if (leftRight == 2)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                    CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                }
                else
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, leftRight, mode);
                    if (CurveUtility.GetKeyTangentMode(keyframe, 1 - leftRight) == TangentMode.Smooth)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 1 - leftRight, TangentMode.Editable);
                    }
                }
                if (mode == TangentMode.Stepped && (leftRight == 0 || leftRight == 2))
                {
                    keyframe.inTangent = float.PositiveInfinity;
                }
                if (mode == TangentMode.Stepped && (leftRight == 1 || leftRight == 2))
                {
                    keyframe.outTangent = float.PositiveInfinity;
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.binding);
                if (!list2.Contains(item))
                {
                    list2.Add(item);
                }
                list.Add(current.curveId);
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(list2, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(list, "Set Tangents");
            }
        }
        public void SetTangent(int leftRight, AnimationUtility.TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> list = new List <ChangedCurve>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                AnimationUtility.SetKeyBroken(ref keyframe, true);
                if (leftRight == 2)
                {
                    AnimationUtility.SetKeyLeftTangentMode(ref keyframe, mode);
                    AnimationUtility.SetKeyRightTangentMode(ref keyframe, mode);
                }
                else if (leftRight == 0)
                {
                    AnimationUtility.SetKeyLeftTangentMode(ref keyframe, mode);
                    if (AnimationUtility.GetKeyRightTangentMode(keyframe) == AnimationUtility.TangentMode.ClampedAuto || AnimationUtility.GetKeyRightTangentMode(keyframe) == AnimationUtility.TangentMode.Auto)
                    {
                        AnimationUtility.SetKeyRightTangentMode(ref keyframe, AnimationUtility.TangentMode.Free);
                    }
                }
                else
                {
                    AnimationUtility.SetKeyRightTangentMode(ref keyframe, mode);
                    if (AnimationUtility.GetKeyLeftTangentMode(keyframe) == AnimationUtility.TangentMode.ClampedAuto || AnimationUtility.GetKeyLeftTangentMode(keyframe) == AnimationUtility.TangentMode.Auto)
                    {
                        AnimationUtility.SetKeyLeftTangentMode(ref keyframe, AnimationUtility.TangentMode.Free);
                    }
                }
                if (mode == AnimationUtility.TangentMode.Constant && (leftRight == 0 || leftRight == 2))
                {
                    keyframe.inTangent = float.PositiveInfinity;
                }
                if (mode == AnimationUtility.TangentMode.Constant && (leftRight == 1 || leftRight == 2))
                {
                    keyframe.outTangent = float.PositiveInfinity;
                }
                curve.MoveKey(current.key, keyframe);
                AnimationUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.curveId, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
            }
            this.updater.UpdateCurves(list, "Set Tangents");
        }
Exemplo n.º 13
0
        public void Flatten(List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> list = new List <ChangedCurve>();

            foreach (KeyIdentifier identifier in keysToSet)
            {
                AnimationCurve curve = identifier.curve;
                Keyframe       key   = identifier.keyframe;
                key.inTangent  = 0f;
                key.outTangent = 0f;
                curve.MoveKey(identifier.key, key);
                AnimationUtility.UpdateTangentsFromModeSurrounding(curve, identifier.key);
                ChangedCurve item = new ChangedCurve(curve, identifier.curveId, identifier.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
            }
            this.updater.UpdateCurves(list, "Set Tangents");
        }
Exemplo n.º 14
0
        public void SetBroken(object _keysToSet)
        {
            List <ChangedCurve>  curve1            = new List <ChangedCurve>();
            List <KeyIdentifier> keyIdentifierList = (List <KeyIdentifier>)_keysToSet;
            List <int>           curveIds          = new List <int>();

            using (List <KeyIdentifier> .Enumerator enumerator = keyIdentifierList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyIdentifier  current  = enumerator.Current;
                    AnimationCurve curve2   = current.curve;
                    Keyframe       keyframe = current.keyframe;
                    CurveUtility.SetKeyBroken(ref keyframe, true);
                    if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Smooth)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 1, TangentMode.Editable);
                    }
                    if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Smooth)
                    {
                        CurveUtility.SetKeyTangentMode(ref keyframe, 0, TangentMode.Editable);
                    }
                    curve2.MoveKey(current.key, keyframe);
                    CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
                    ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
                    if (!curve1.Contains(changedCurve))
                    {
                        curve1.Add(changedCurve);
                    }
                    curveIds.Add(current.curveId);
                }
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(curve1, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(curveIds, "Set Tangents");
            }
        }
Exemplo n.º 15
0
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> curve1   = new List <ChangedCurve>();
            List <int>          curveIds = new List <int>();

            using (List <KeyIdentifier> .Enumerator enumerator = keysToSet.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyIdentifier  current  = enumerator.Current;
                    AnimationCurve curve2   = current.curve;
                    Keyframe       keyframe = current.keyframe;
                    CurveUtility.SetKeyBroken(ref keyframe, false);
                    CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                    CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                    if (mode == TangentMode.Editable)
                    {
                        float smoothTangent = CurveUtility.CalculateSmoothTangent(keyframe);
                        keyframe.inTangent  = smoothTangent;
                        keyframe.outTangent = smoothTangent;
                    }
                    curve2.MoveKey(current.key, keyframe);
                    CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
                    ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
                    if (!curve1.Contains(changedCurve))
                    {
                        curve1.Add(changedCurve);
                    }
                    curveIds.Add(current.curveId);
                }
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(curve1, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(curveIds, "Set Tangents");
            }
        }
        public void Flatten(List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> changedCurves = new List <ChangedCurve>();

            foreach (KeyIdentifier keyToSet in keysToSet)
            {
                AnimationCurve animationCurve = keyToSet.curve;
                Keyframe       key            = keyToSet.keyframe;
                key.inTangent  = 0;
                key.outTangent = 0;
                animationCurve.MoveKey(keyToSet.key, key);
                AnimationUtility.UpdateTangentsFromModeSurrounding(animationCurve, keyToSet.key);

                ChangedCurve changedCurve = new ChangedCurve(animationCurve, keyToSet.curveId, keyToSet.binding);
                if (!changedCurves.Contains(changedCurve))
                {
                    changedCurves.Add(changedCurve);
                }
            }

            updater.UpdateCurves(changedCurves, "Set Tangents");
        }
Exemplo n.º 17
0
        public void SetBroken(object _keysToSet)
        {
            List <ChangedCurve>  list  = new List <ChangedCurve>();
            List <KeyIdentifier> list2 = (List <KeyIdentifier>)_keysToSet;
            List <int>           list3 = new List <int>();

            foreach (KeyIdentifier current in list2)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, true);
                if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Smooth)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 1, TangentMode.Editable);
                }
                if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Smooth)
                {
                    CurveUtility.SetKeyTangentMode(ref keyframe, 0, TangentMode.Editable);
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
                list3.Add(current.curveId);
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(list, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(list3, "Set Tangents");
            }
        }
Exemplo n.º 18
0
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <ChangedCurve> list  = new List <ChangedCurve>();
            List <int>          list2 = new List <int>();

            foreach (KeyIdentifier current in keysToSet)
            {
                AnimationCurve curve    = current.curve;
                Keyframe       keyframe = current.keyframe;
                CurveUtility.SetKeyBroken(ref keyframe, false);
                CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
                CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
                if (mode == TangentMode.Editable)
                {
                    float num = CurveUtility.CalculateSmoothTangent(keyframe);
                    keyframe.inTangent  = num;
                    keyframe.outTangent = num;
                }
                curve.MoveKey(current.key, keyframe);
                CurveUtility.UpdateTangentsFromModeSurrounding(curve, current.key);
                ChangedCurve item = new ChangedCurve(curve, current.binding);
                if (!list.Contains(item))
                {
                    list.Add(item);
                }
                list2.Add(current.curveId);
            }
            if (this.updater is DopeSheetEditor)
            {
                this.updater.UpdateCurves(list, "Set Tangents");
            }
            else
            {
                this.updater.UpdateCurves(list2, "Set Tangents");
            }
        }
Exemplo n.º 19
0
 public void SetTangent(int leftRight, AnimationUtility.TangentMode mode, List<KeyIdentifier> keysToSet)
 {
     List<ChangedCurve> list = new List<ChangedCurve>();
     foreach (KeyIdentifier identifier in keysToSet)
     {
         AnimationCurve curve = identifier.curve;
         Keyframe key = identifier.keyframe;
         AnimationUtility.SetKeyBroken(ref key, true);
         if (leftRight == 2)
         {
             AnimationUtility.SetKeyLeftTangentMode(ref key, mode);
             AnimationUtility.SetKeyRightTangentMode(ref key, mode);
         }
         else if (leftRight == 0)
         {
             AnimationUtility.SetKeyLeftTangentMode(ref key, mode);
             if ((AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto) || (AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.Auto))
             {
                 AnimationUtility.SetKeyRightTangentMode(ref key, AnimationUtility.TangentMode.Free);
             }
         }
         else
         {
             AnimationUtility.SetKeyRightTangentMode(ref key, mode);
             if ((AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto) || (AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.Auto))
             {
                 AnimationUtility.SetKeyLeftTangentMode(ref key, AnimationUtility.TangentMode.Free);
             }
         }
         if ((mode == AnimationUtility.TangentMode.Constant) && ((leftRight == 0) || (leftRight == 2)))
         {
             key.inTangent = float.PositiveInfinity;
         }
         if ((mode == AnimationUtility.TangentMode.Constant) && ((leftRight == 1) || (leftRight == 2)))
         {
             key.outTangent = float.PositiveInfinity;
         }
         curve.MoveKey(identifier.key, key);
         AnimationUtility.UpdateTangentsFromModeSurrounding(curve, identifier.key);
         ChangedCurve item = new ChangedCurve(curve, identifier.curveId, identifier.binding);
         if (!list.Contains(item))
         {
             list.Add(item);
         }
     }
     this.updater.UpdateCurves(list, "Set Tangents");
 }
 public void SetBoth(TangentMode mode, List<KeyIdentifier> keysToSet)
 {
   List<ChangedCurve> curve1 = new List<ChangedCurve>();
   List<int> curveIds = new List<int>();
   using (List<KeyIdentifier>.Enumerator enumerator = keysToSet.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       KeyIdentifier current = enumerator.Current;
       AnimationCurve curve2 = current.curve;
       Keyframe keyframe = current.keyframe;
       CurveUtility.SetKeyBroken(ref keyframe, false);
       CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
       CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
       if (mode == TangentMode.Editable)
       {
         float smoothTangent = CurveUtility.CalculateSmoothTangent(keyframe);
         keyframe.inTangent = smoothTangent;
         keyframe.outTangent = smoothTangent;
       }
       curve2.MoveKey(current.key, keyframe);
       CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
       ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
       if (!curve1.Contains(changedCurve))
         curve1.Add(changedCurve);
       curveIds.Add(current.curveId);
     }
   }
   if (this.updater is DopeSheetEditor)
     this.updater.UpdateCurves(curve1, "Set Tangents");
   else
     this.updater.UpdateCurves(curveIds, "Set Tangents");
 }
 public void Flatten(List<KeyIdentifier> keysToSet)
 {
   List<ChangedCurve> curve1 = new List<ChangedCurve>();
   List<int> curveIds = new List<int>();
   using (List<KeyIdentifier>.Enumerator enumerator = keysToSet.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       KeyIdentifier current = enumerator.Current;
       AnimationCurve curve2 = current.curve;
       Keyframe keyframe = current.keyframe;
       keyframe.inTangent = 0.0f;
       keyframe.outTangent = 0.0f;
       curve2.MoveKey(current.key, keyframe);
       CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
       ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
       if (!curve1.Contains(changedCurve))
         curve1.Add(changedCurve);
       curveIds.Add(current.curveId);
     }
   }
   if (this.updater is DopeSheetEditor)
     this.updater.UpdateCurves(curve1, "Set Tangents");
   else
     this.updater.UpdateCurves(curveIds, "Set Tangents");
 }
 public void SetBroken(object _keysToSet)
 {
   List<ChangedCurve> curve1 = new List<ChangedCurve>();
   List<KeyIdentifier> keyIdentifierList = (List<KeyIdentifier>) _keysToSet;
   List<int> curveIds = new List<int>();
   using (List<KeyIdentifier>.Enumerator enumerator = keyIdentifierList.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       KeyIdentifier current = enumerator.Current;
       AnimationCurve curve2 = current.curve;
       Keyframe keyframe = current.keyframe;
       CurveUtility.SetKeyBroken(ref keyframe, true);
       if (CurveUtility.GetKeyTangentMode(keyframe, 1) == TangentMode.Smooth)
         CurveUtility.SetKeyTangentMode(ref keyframe, 1, TangentMode.Editable);
       if (CurveUtility.GetKeyTangentMode(keyframe, 0) == TangentMode.Smooth)
         CurveUtility.SetKeyTangentMode(ref keyframe, 0, TangentMode.Editable);
       curve2.MoveKey(current.key, keyframe);
       CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
       ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
       if (!curve1.Contains(changedCurve))
         curve1.Add(changedCurve);
       curveIds.Add(current.curveId);
     }
   }
   if (this.updater is DopeSheetEditor)
     this.updater.UpdateCurves(curve1, "Set Tangents");
   else
     this.updater.UpdateCurves(curveIds, "Set Tangents");
 }
 public void SetTangent(int leftRight, TangentMode mode, List<KeyIdentifier> keysToSet)
 {
   List<int> curveIds = new List<int>();
   List<ChangedCurve> curve1 = new List<ChangedCurve>();
   using (List<KeyIdentifier>.Enumerator enumerator = keysToSet.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       KeyIdentifier current = enumerator.Current;
       AnimationCurve curve2 = current.curve;
       Keyframe keyframe = current.keyframe;
       CurveUtility.SetKeyBroken(ref keyframe, true);
       if (leftRight == 2)
       {
         CurveUtility.SetKeyTangentMode(ref keyframe, 0, mode);
         CurveUtility.SetKeyTangentMode(ref keyframe, 1, mode);
       }
       else
       {
         CurveUtility.SetKeyTangentMode(ref keyframe, leftRight, mode);
         if (CurveUtility.GetKeyTangentMode(keyframe, 1 - leftRight) == TangentMode.Smooth)
           CurveUtility.SetKeyTangentMode(ref keyframe, 1 - leftRight, TangentMode.Editable);
       }
       if (mode == TangentMode.Stepped && (leftRight == 0 || leftRight == 2))
         keyframe.inTangent = float.PositiveInfinity;
       if (mode == TangentMode.Stepped && (leftRight == 1 || leftRight == 2))
         keyframe.outTangent = float.PositiveInfinity;
       curve2.MoveKey(current.key, keyframe);
       CurveUtility.UpdateTangentsFromModeSurrounding(curve2, current.key);
       ChangedCurve changedCurve = new ChangedCurve(curve2, current.binding);
       if (!curve1.Contains(changedCurve))
         curve1.Add(changedCurve);
       curveIds.Add(current.curveId);
     }
   }
   if (this.updater is DopeSheetEditor)
     this.updater.UpdateCurves(curve1, "Set Tangents");
   else
     this.updater.UpdateCurves(curveIds, "Set Tangents");
 }
Exemplo n.º 24
0
 public void Flatten(List<KeyIdentifier> keysToSet)
 {
     List<ChangedCurve> list = new List<ChangedCurve>();
     foreach (KeyIdentifier identifier in keysToSet)
     {
         AnimationCurve curve = identifier.curve;
         Keyframe key = identifier.keyframe;
         key.inTangent = 0f;
         key.outTangent = 0f;
         curve.MoveKey(identifier.key, key);
         AnimationUtility.UpdateTangentsFromModeSurrounding(curve, identifier.key);
         ChangedCurve item = new ChangedCurve(curve, identifier.curveId, identifier.binding);
         if (!list.Contains(item))
         {
             list.Add(item);
         }
     }
     this.updater.UpdateCurves(list, "Set Tangents");
 }
Exemplo n.º 25
0
 public void SetBoth(AnimationUtility.TangentMode mode, List<KeyIdentifier> keysToSet)
 {
     List<ChangedCurve> list = new List<ChangedCurve>();
     foreach (KeyIdentifier identifier in keysToSet)
     {
         AnimationCurve curve = identifier.curve;
         Keyframe key = identifier.keyframe;
         AnimationUtility.SetKeyBroken(ref key, false);
         AnimationUtility.SetKeyRightTangentMode(ref key, mode);
         AnimationUtility.SetKeyLeftTangentMode(ref key, mode);
         if (mode == AnimationUtility.TangentMode.Free)
         {
             float num = CurveUtility.CalculateSmoothTangent(key);
             key.inTangent = num;
             key.outTangent = num;
         }
         curve.MoveKey(identifier.key, key);
         AnimationUtility.UpdateTangentsFromModeSurrounding(curve, identifier.key);
         ChangedCurve item = new ChangedCurve(curve, identifier.curveId, identifier.binding);
         if (!list.Contains(item))
         {
             list.Add(item);
         }
     }
     this.updater.UpdateCurves(list, "Set Tangents");
 }
Exemplo n.º 26
0
 public void SetBroken(object _keysToSet)
 {
     List<ChangedCurve> list = new List<ChangedCurve>();
     List<KeyIdentifier> list2 = (List<KeyIdentifier>) _keysToSet;
     foreach (KeyIdentifier identifier in list2)
     {
         AnimationCurve curve = identifier.curve;
         Keyframe key = identifier.keyframe;
         AnimationUtility.SetKeyBroken(ref key, true);
         if ((AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto) || (AnimationUtility.GetKeyRightTangentMode(key) == AnimationUtility.TangentMode.Auto))
         {
             AnimationUtility.SetKeyRightTangentMode(ref key, AnimationUtility.TangentMode.Free);
         }
         if ((AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.ClampedAuto) || (AnimationUtility.GetKeyLeftTangentMode(key) == AnimationUtility.TangentMode.Auto))
         {
             AnimationUtility.SetKeyLeftTangentMode(ref key, AnimationUtility.TangentMode.Free);
         }
         curve.MoveKey(identifier.key, key);
         AnimationUtility.UpdateTangentsFromModeSurrounding(curve, identifier.key);
         ChangedCurve item = new ChangedCurve(curve, identifier.curveId, identifier.binding);
         if (!list.Contains(item))
         {
             list.Add(item);
         }
     }
     this.updater.UpdateCurves(list, "Set Tangents");
 }