diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs index 02500f95f..6c6c9ba8e 100644 --- a/Source/Editor/GUI/CurveEditor.cs +++ b/Source/Editor/GUI/CurveEditor.cs @@ -289,7 +289,7 @@ namespace FlaxEditor.GUI /// /// The curve time/value axes tick steps. /// - protected float[] TickSteps = Utilities.Utils.CurveTickSteps; + protected double[] TickSteps = Utilities.Utils.CurveTickSteps; /// /// The curve contents area. @@ -797,9 +797,9 @@ namespace FlaxEditor.GUI private void DrawAxis(Float2 axis, Rectangle viewRect, float min, float max, float pixelRange) { - Utilities.Utils.DrawCurveTicks((float tick, float strength) => + Utilities.Utils.DrawCurveTicks((decimal tick, float strength) => { - var p = PointFromKeyframes(axis * tick, ref viewRect); + var p = PointFromKeyframes(axis * (float)tick, ref viewRect); // Draw line var lineRect = new Rectangle diff --git a/Source/Editor/GUI/Timeline/GUI/Background.cs b/Source/Editor/GUI/Timeline/GUI/Background.cs index 57b09324e..b1087a682 100644 --- a/Source/Editor/GUI/Timeline/GUI/Background.cs +++ b/Source/Editor/GUI/Timeline/GUI/Background.cs @@ -14,7 +14,7 @@ namespace FlaxEditor.GUI.Timeline.GUI class Background : ContainerControl { private readonly Timeline _timeline; - private float[] _tickSteps; + private double[] _tickSteps; private float[] _tickStrengths; private bool _isSelecting; private Float2 _selectingStartPos = Float2.Minimum; @@ -176,9 +176,9 @@ namespace FlaxEditor.GUI.Timeline.GUI // Draw vertical lines for time axis var pixelsInRange = _timeline.Zoom; var pixelRange = pixelsInRange * (max - min); - var tickRange = Utilities.Utils.DrawCurveTicks((float tick, float strength) => + var tickRange = Utilities.Utils.DrawCurveTicks((decimal tick, float strength) => { - var time = tick / _timeline.FramesPerSecond; + var time = (float)tick / _timeline.FramesPerSecond; var x = time * zoom + Timeline.StartOffset; var lineColor = style.ForegroundDisabled.RGBMultiplied(0.7f).AlphaMultiplied(strength); Render2D.FillRectangle(new Rectangle(x - 0.5f, 0, 1.0f, height), lineColor); @@ -233,20 +233,20 @@ namespace FlaxEditor.GUI.Timeline.GUI int l = Mathf.Clamp(smallestTick + level, 0, _tickSteps.Length - 2); var lStep = _tickSteps[l]; var lNextStep = _tickSteps[l + 1]; - int startTick = Mathf.FloorToInt(min / lStep); - int endTick = Mathf.CeilToInt(max / lStep); + var startTick = Mathd.FloorToInt(min / lStep); + var endTick = Mathd.CeilToInt(max / lStep); Color lineColor = style.Foreground.RGBMultiplied(0.8f).AlphaMultiplied(strength); Color labelColor = style.ForegroundDisabled.AlphaMultiplied(strength); - for (int i = startTick; i <= endTick; i++) + for (var i = startTick; i <= endTick; i++) { - if (l < biggestTick && (i % Mathf.RoundToInt(lNextStep / lStep) == 0)) + if (l < biggestTick && (i % Mathd.RoundToInt(lNextStep / lStep) == 0)) continue; - var tick = i * lStep; - var time = tick / _timeline.FramesPerSecond; - var x = time * zoom + Timeline.StartOffset; + var tick = (decimal)lStep * i; + var time = (double)tick / _timeline.FramesPerSecond; + var x = (float)time * zoom + Timeline.StartOffset; // Header line - var lineRect = new Rectangle(x - 0.5f, -verticalLinesHeaderExtend * 0.6f + timeAxisHeaderOffset, 1.0f, verticalLinesHeaderExtend * 0.6f); + var lineRect = new Rectangle((float)x - 0.5f, -verticalLinesHeaderExtend * 0.6f + timeAxisHeaderOffset, 1.0f, verticalLinesHeaderExtend * 0.6f); Render2D.FillRectangle(lineRect, lineColor); // Time label diff --git a/Source/Editor/Gizmo/UIEditorGizmo.cs b/Source/Editor/Gizmo/UIEditorGizmo.cs index 502f19f96..7b4e79441 100644 --- a/Source/Editor/Gizmo/UIEditorGizmo.cs +++ b/Source/Editor/Gizmo/UIEditorGizmo.cs @@ -150,7 +150,8 @@ namespace FlaxEditor private float _mouseMoveSum; private UndoMultiBlock _undoBlock; private View _view; - private float[] _gridTickSteps = Utilities.Utils.CurveTickSteps, _gridTickStrengths; + private double[] _gridTickSteps = Utilities.Utils.CurveTickSteps; + private float[] _gridTickStrengths; private List _widgets; private Widget _activeWidget; @@ -564,9 +565,9 @@ namespace FlaxEditor var linesColor = style.ForegroundDisabled.RGBMultiplied(0.5f); var labelsColor = style.ForegroundDisabled; var labelsSize = 10.0f; - Utilities.Utils.DrawCurveTicks((float tick, float strength) => + Utilities.Utils.DrawCurveTicks((decimal tick, float strength) => { - var p = _view.PointToParent(axis * tick); + var p = _view.PointToParent(axis * (float)tick); // Draw line var lineRect = new Rectangle diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index db824857a..36e847f2d 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -236,19 +236,19 @@ namespace FlaxEditor.Utilities /// /// The time/value axes tick steps for editors with timeline. /// - internal static readonly float[] CurveTickSteps = + internal static readonly double[] CurveTickSteps = { - 0.0000001f, 0.0000005f, 0.000001f, 0.000005f, 0.00001f, - 0.00005f, 0.0001f, 0.0005f, 0.001f, 0.005f, - 0.01f, 0.05f, 0.1f, 0.5f, 1, + 0.0000001, 0.0000005, 0.000001, 0.000005, 0.00001, + 0.00005, 0.0001, 0.0005, 0.001, 0.005, + 0.01, 0.05, 0.1, 0.5, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000, 5000000, 10000000, 100000000 }; - internal delegate void DrawCurveTick(float tick, float strength); + internal delegate void DrawCurveTick(decimal tick, float strength); - internal static Int2 DrawCurveTicks(DrawCurveTick drawTick, float[] tickSteps, ref float[] tickStrengths, float min, float max, float pixelRange, float minDistanceBetweenTicks = 20, float maxDistanceBetweenTicks = 60) + internal static Int2 DrawCurveTicks(DrawCurveTick drawTick, double[] tickSteps, ref float[] tickStrengths, float min, float max, float pixelRange, float minDistanceBetweenTicks = 20, float maxDistanceBetweenTicks = 60) { if (pixelRange <= Mathf.Epsilon || maxDistanceBetweenTicks <= minDistanceBetweenTicks) return Int2.Zero; @@ -262,10 +262,10 @@ namespace FlaxEditor.Utilities for (int i = tickSteps.Length - 1; i >= 0; i--) { // Calculate how far apart these modulo tick steps are spaced - float tickSpacing = tickSteps[i] * pixelsInRange; + var tickSpacing = tickSteps[i] * pixelsInRange; // Calculate the strength of the tick markers based on the spacing - tickStrengths[i] = Mathf.Saturate((tickSpacing - minDistanceBetweenTicks) / (maxDistanceBetweenTicks - minDistanceBetweenTicks)); + tickStrengths[i] = (float)Mathd.Saturate((tickSpacing - minDistanceBetweenTicks) / (maxDistanceBetweenTicks - minDistanceBetweenTicks)); // Beyond threshold the ticks don't get any bigger or fatter if (tickStrengths[i] >= 1) @@ -283,7 +283,7 @@ namespace FlaxEditor.Utilities // Draw all tick levels for (int level = 0; level < tickLevels; level++) { - float strength = tickStrengths[smallestTick + level]; + var strength = tickStrengths[smallestTick + level]; if (strength <= Mathf.Epsilon) continue; @@ -291,13 +291,13 @@ namespace FlaxEditor.Utilities int l = Mathf.Clamp(smallestTick + level, 0, tickSteps.Length - 2); var lStep = tickSteps[l]; var lNextStep = tickSteps[l + 1]; - int startTick = Mathf.FloorToInt(min / lStep); - int endTick = Mathf.CeilToInt(max / lStep); - for (int i = startTick; i <= endTick; i++) + var startTick = Mathd.FloorToInt(min / lStep); + var endTick = Mathd.CeilToInt(max / lStep); + for (var i = startTick; i <= endTick; i++) { - if (l < biggestTick && (i % Mathf.RoundToInt(lNextStep / lStep) == 0)) + if (l < biggestTick && (i % Mathd.RoundToInt(lNextStep / lStep) == 0)) continue; - var tick = i * lStep; + var tick = (decimal)lStep * i; drawTick(tick, strength); } }