예제 #1
0
		public void UpdateCurvesFromPoints(Vector2 movement)
		{
			this.m_DisplayedSelection = new List<CurveSelection>();
			foreach (CurveEditor.SavedCurve current in this.m_CurveBackups)
			{
				List<CurveEditor.SavedCurve.SavedKeyFrame> list = new List<CurveEditor.SavedCurve.SavedKeyFrame>(current.keys.Count);
				int num;
				int num2;
				int num3;
				if (movement.x <= 0f)
				{
					num = 0;
					num2 = current.keys.Count;
					num3 = 1;
				}
				else
				{
					num = current.keys.Count - 1;
					num2 = -1;
					num3 = -1;
				}
				for (int num4 = num; num4 != num2; num4 += num3)
				{
					CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame = current.keys[num4];
					if (savedKeyFrame.selected != CurveWrapper.SelectionMode.None)
					{
						savedKeyFrame = new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected);
						savedKeyFrame.key.time = Mathf.Clamp(savedKeyFrame.key.time + movement.x, base.hRangeMin, base.hRangeMax);
						if (savedKeyFrame.selected == CurveWrapper.SelectionMode.Selected)
						{
							savedKeyFrame.key.value = this.ClampVerticalValue(savedKeyFrame.key.value + movement.y, current.curveId);
						}
						for (int i = list.Count - 1; i >= 0; i--)
						{
							if (Mathf.Abs(list[i].key.time - savedKeyFrame.key.time) < 1E-05f)
							{
								list.RemoveAt(i);
							}
						}
					}
					list.Add(new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected));
				}
				list.Sort();
				Keyframe[] array = new Keyframe[list.Count];
				for (int j = 0; j < list.Count; j++)
				{
					CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame2 = list[j];
					array[j] = savedKeyFrame2.key;
					if (savedKeyFrame2.selected != CurveWrapper.SelectionMode.None)
					{
						CurveSelection curveSelection = new CurveSelection(current.curveId, this, j);
						if (savedKeyFrame2.selected == CurveWrapper.SelectionMode.SemiSelected)
						{
							curveSelection.semiSelected = true;
						}
						this.m_DisplayedSelection.Add(curveSelection);
					}
				}
				CurveWrapper curveFromID = this.GetCurveFromID(current.curveId);
				curveFromID.curve.keys = array;
				curveFromID.changed = true;
			}
			this.UpdateTangentsFromSelection();
		}
예제 #2
0
 private void UpdateCurvesFromPoints(System.Action<CurveEditor.SavedCurve.SavedKeyFrame, CurveEditor.SavedCurve> action)
 {
   List<CurveSelection> curveSelectionList = new List<CurveSelection>();
   using (List<CurveEditor.SavedCurve>.Enumerator enumerator = this.m_CurveBackups.GetEnumerator())
   {
     while (enumerator.MoveNext())
     {
       CurveEditor.SavedCurve current = enumerator.Current;
       List<CurveEditor.SavedCurve.SavedKeyFrame> savedKeyFrameList = new List<CurveEditor.SavedCurve.SavedKeyFrame>(current.keys.Count);
       for (int index1 = 0; index1 != current.keys.Count; ++index1)
       {
         CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame = current.keys[index1];
         if (savedKeyFrame.selected != CurveWrapper.SelectionMode.None)
         {
           savedKeyFrame = new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected);
           action(savedKeyFrame, current);
           for (int index2 = savedKeyFrameList.Count - 1; index2 >= 0; --index2)
           {
             if ((double) Mathf.Abs(savedKeyFrameList[index2].key.time - savedKeyFrame.key.time) < 9.99999974737875E-06)
               savedKeyFrameList.RemoveAt(index2);
           }
         }
         savedKeyFrameList.Add(new CurveEditor.SavedCurve.SavedKeyFrame(savedKeyFrame.key, savedKeyFrame.selected));
       }
       savedKeyFrameList.Sort();
       Keyframe[] keyframeArray = new Keyframe[savedKeyFrameList.Count];
       for (int keyIndex = 0; keyIndex < savedKeyFrameList.Count; ++keyIndex)
       {
         CurveEditor.SavedCurve.SavedKeyFrame savedKeyFrame = savedKeyFrameList[keyIndex];
         keyframeArray[keyIndex] = savedKeyFrame.key;
         if (savedKeyFrame.selected != CurveWrapper.SelectionMode.None)
         {
           CurveSelection curveSelection = new CurveSelection(current.curveId, this, keyIndex);
           if (savedKeyFrame.selected == CurveWrapper.SelectionMode.SemiSelected)
             curveSelection.semiSelected = true;
           curveSelectionList.Add(curveSelection);
         }
       }
       this.selectedCurves = curveSelectionList;
       CurveWrapper curveFromId = this.GetCurveFromID(current.curveId);
       curveFromId.curve.keys = keyframeArray;
       curveFromId.changed = true;
     }
   }
   this.UpdateTangentsFromSelection();
 }