예제 #1
0
        private Keyframe[] NormalizeKeys(Keyframe[] sourceKeys, CurveEditorWindow.NormalizationMode normalization)
        {
            Rect rect;

            if (!this.GetNormalizationRect(out rect))
            {
                normalization = CurveEditorWindow.NormalizationMode.None;
            }
            return(CurveEditorWindow.CopyAndScaleCurveKeys(sourceKeys, rect, normalization));
        }
예제 #2
0
 private static Keyframe[] CopyAndScaleCurveKeys(Keyframe[] orgKeys, Rect rect, CurveEditorWindow.NormalizationMode normalization)
 {
     Keyframe[] array = new Keyframe[orgKeys.Length];
     orgKeys.CopyTo(array, 0);
     Keyframe[] result;
     if (normalization == CurveEditorWindow.NormalizationMode.None)
     {
         result = array;
     }
     else if (rect.width == 0f || rect.height == 0f || float.IsInfinity(rect.width) || float.IsInfinity(rect.height))
     {
         Debug.LogError("CopyAndScaleCurve: Invalid scale: " + rect);
         result = array;
     }
     else
     {
         float num = rect.height / rect.width;
         if (normalization != CurveEditorWindow.NormalizationMode.Normalize)
         {
             if (normalization == CurveEditorWindow.NormalizationMode.Denormalize)
             {
                 for (int i = 0; i < array.Length; i++)
                 {
                     array[i].time  = orgKeys[i].time * rect.width + rect.xMin;
                     array[i].value = orgKeys[i].value * rect.height + rect.yMin;
                     if (!float.IsInfinity(orgKeys[i].inTangent))
                     {
                         array[i].inTangent = orgKeys[i].inTangent * num;
                     }
                     if (!float.IsInfinity(orgKeys[i].outTangent))
                     {
                         array[i].outTangent = orgKeys[i].outTangent * num;
                     }
                 }
             }
         }
         else
         {
             for (int j = 0; j < array.Length; j++)
             {
                 array[j].time  = (orgKeys[j].time - rect.xMin) / rect.width;
                 array[j].value = (orgKeys[j].value - rect.yMin) / rect.height;
                 if (!float.IsInfinity(orgKeys[j].inTangent))
                 {
                     array[j].inTangent = orgKeys[j].inTangent / num;
                 }
                 if (!float.IsInfinity(orgKeys[j].outTangent))
                 {
                     array[j].outTangent = orgKeys[j].outTangent / num;
                 }
             }
         }
         result = array;
     }
     return(result);
 }