CalculateSmoothTangent() public static method

public static CalculateSmoothTangent ( Keyframe key ) : float
key UnityEngine.Keyframe
return float
        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");
        }
        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");
        }
Ejemplo n.º 3
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");
            }
        }
Ejemplo n.º 4
0
        public void SetBoth(TangentMode mode, List <KeyIdentifier> keysToSet)
        {
            List <int> list = 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);
                list.Add(current.curveId);
            }
            this.updater.UpdateCurves(list, "Set Tangents");
        }
Ejemplo n.º 5
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");
            }
        }