Exemplo n.º 1
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");
            }
        }
Exemplo n.º 2
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");
            }
        }
Exemplo n.º 3
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.º 4
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");
            }
        }