Explorar o código

Properly calculate time from animation frame index in animation editor's GUI elements

BearishSun %!s(int64=9) %!d(string=hai) anos
pai
achega
1ed6a76477
Modificáronse 1 ficheiros con 16 adicións e 26 borrados
  1. 16 26
      Source/MBansheeEditor/Windows/Animation/GUITimelineBase.cs

+ 16 - 26
Source/MBansheeEditor/Windows/Animation/GUITimelineBase.cs

@@ -94,11 +94,7 @@ namespace BansheeEditor
         /// <returns>Time of the frame with the provided index. </returns>
         public float GetTimeForFrame(int frameIdx)
         {
-            float range = GetRange();
-            int numFrames = (int)(range * fps);
-            float timePerFrame = range / numFrames;
-
-            return frameIdx * timePerFrame;
+            return frameIdx / (float)fps;
         }
 
         /// <summary>
@@ -153,20 +149,6 @@ namespace BansheeEditor
             this.fps = Math.Max(1, fps);
         }
 
-        /// <summary>
-        /// Draws a vertical frame marker at the specified time.
-        /// </summary>
-        /// <param name="t">Time at which to draw the marker.</param>
-        private void DrawFrameMarker(float t)
-        {
-            int xPos = (int)(((t - rangeOffset) / GetRange()) * drawableWidth) + PADDING;
-
-            Vector2I start = new Vector2I(xPos, 0);
-            Vector2I end = new Vector2I(xPos, height);
-
-            canvas.DrawLine(start, end, Color.BansheeOrange);
-        }
-
         /// <summary>
         /// Returns the range of times displayed by the timeline rounded to the multiple of FPS.
         /// </summary>
@@ -186,19 +168,27 @@ namespace BansheeEditor
             return MathEx.Max(1.0f, range / spf) * spf;
         }
 
+        /// <summary>
+        /// Draws a vertical frame marker at the specified time.
+        /// </summary>
+        /// <param name="t">Time at which to draw the marker.</param>
+        private void DrawFrameMarker(float t)
+        {
+            int xPos = (int)(((t - rangeOffset) / GetRange()) * drawableWidth) + PADDING;
+
+            Vector2I start = new Vector2I(xPos, 0);
+            Vector2I end = new Vector2I(xPos, height);
+
+            canvas.DrawLine(start, end, Color.BansheeOrange);
+        }
+
         /// <summary>
         /// Draws the frame marker at the currently selected frame.
         /// </summary>
         protected void DrawFrameMarker()
         {
             if (markedFrameIdx != -1)
-            {
-                float range = GetRange();
-                int numFrames = (int)(range * fps);
-                float timePerFrame = range / numFrames;
-
-                DrawFrameMarker(markedFrameIdx * timePerFrame);
-            }
+                DrawFrameMarker(markedFrameIdx / (float)fps);
         }
 
         /// <summary>