Bläddra i källkod

Neatly round values on animation editor's value axis
Properly render timeline for ranges lower than a single frame

BearishSun 9 år sedan
förälder
incheckning
22865ed4cc

+ 1 - 0
Source/MBansheeEditor/Windows/Animation/GUIGraphTicks.cs

@@ -1,6 +1,7 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 using System;
+using System.Text;
 using BansheeEngine;
 
 namespace BansheeEditor

+ 5 - 2
Source/MBansheeEditor/Windows/Animation/GUIGraphValues.cs

@@ -84,9 +84,12 @@ namespace BansheeEditor
         /// <param name="yPos">Position to draw the text at.</param>
         /// <param name="value">Value to display.</param>
         /// <param name="above">If true the text will be displayed above the provided position, otherwise below.</param>
-        private void DrawValue(int yPos, float value,  bool above)
+        private void DrawValue(int yPos, float value, bool above)
         {
-            string valueString = value.ToString();
+            int exponent = MathEx.FloorToInt(MathEx.Log10(MathEx.Abs(value)));
+            int maxDecimalPoints = MathEx.Max(0, 1 - exponent);
+
+            string valueString = value.ToString("F" + maxDecimalPoints);
 
             Vector2I textBounds = GUIUtility.CalculateTextBounds(valueString, EditorBuiltin.DefaultFont,
                 EditorStyles.DefaultFontSize);

+ 1 - 1
Source/MBansheeEditor/Windows/Animation/GUITimelineBase.cs

@@ -169,7 +169,7 @@ namespace BansheeEditor
                 range += lengthPerPixel * PADDING;
             }
 
-            return ((int)range / spf) * spf;
+            return MathEx.Max(1.0f, range / spf) * spf;
         }
 
         /// <summary>