Code cleanup

#1456
This commit is contained in:
Wojtek Figat
2024-09-11 19:57:57 +02:00
parent 91bfb29d33
commit c26a806a35
13 changed files with 95 additions and 115 deletions

View File

@@ -382,6 +382,20 @@ namespace FlaxEditor.Options
[EditorDisplay("Visject"), EditorOrder(550), Tooltip("Shows/hides the description panel in the visual scripting context menu.")] [EditorDisplay("Visject"), EditorOrder(550), Tooltip("Shows/hides the description panel in the visual scripting context menu.")]
public bool VisualScriptingDescriptionPanel { get; set; } = true; public bool VisualScriptingDescriptionPanel { get; set; } = true;
/// <summary>
/// Gets or sets the surface grid snapping option.
/// </summary>
[DefaultValue(false)]
[EditorDisplay("Visject", "Grid Snapping"), EditorOrder(551), Tooltip("Toggles grid snapping when moving nodes.")]
public bool SurfaceGridSnapping { get; set; } = false;
/// <summary>
/// Gets or sets the surface grid snapping option.
/// </summary>
[DefaultValue(20.0f)]
[EditorDisplay("Visject", "Grid Snapping Size"), EditorOrder(551), Tooltip("Defines the size of the grid for nodes snapping."), VisibleIf(nameof(SurfaceGridSnapping))]
public float SurfaceGridSnappingSize { get; set; } = 20.0f;
private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont); private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);
private static FontAsset ConsoleFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.InconsolataRegularFont); private static FontAsset ConsoleFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.InconsolataRegularFont);

View File

@@ -109,7 +109,6 @@ namespace FlaxEditor.Surface
/// </summary> /// </summary>
public CreateCustomNodeFunc Create; public CreateCustomNodeFunc Create;
private Float2 _size;
/// <summary> /// <summary>
/// Function for asynchronously loaded nodes to check if input ports are compatible, for filtering. /// Function for asynchronously loaded nodes to check if input ports are compatible, for filtering.
/// </summary> /// </summary>
@@ -123,17 +122,7 @@ namespace FlaxEditor.Surface
/// <summary> /// <summary>
/// Default initial size of the node. /// Default initial size of the node.
/// </summary> /// </summary>
public Float2 Size public Float2 Size;
{
get
{
return _size;
}
set
{
_size = VisjectSurface.RoundToGrid(value, true);
}
}
/// <summary> /// <summary>
/// Custom set of flags. /// Custom set of flags.

View File

@@ -2,7 +2,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
@@ -10,12 +9,9 @@ using FlaxEditor.CustomEditors;
using FlaxEditor.CustomEditors.Elements; using FlaxEditor.CustomEditors.Elements;
using FlaxEditor.Options; using FlaxEditor.Options;
using FlaxEditor.Scripting; using FlaxEditor.Scripting;
using FlaxEditor.Utilities;
using FlaxEngine.Utilities; using FlaxEngine.Utilities;
using FlaxEngine; using FlaxEngine;
using FlaxEditor.GUI; using FlaxEditor.GUI;
using FlaxEngine.GUI;
using FlaxEditor.Options;
namespace FlaxEditor.Surface namespace FlaxEditor.Surface
{ {
@@ -560,41 +556,32 @@ namespace FlaxEditor.Surface
return AreScriptTypesEqualInner(left, right) || AreScriptTypesEqualInner(right, left); return AreScriptTypesEqualInner(left, right) || AreScriptTypesEqualInner(right, left);
} }
// This might not be the greatest place to put this but I couldn't find anything better yet. internal static void PerformCommonSetup(Windows.Assets.AssetEditorWindow window, ToolStrip toolStrip, VisjectSurface surface,
public static void VisjectCommonToolstripSetup(Editor editor, ToolStrip toolStrip, FlaxEditor.Undo undo, out ToolStripButton saveButton, out ToolStripButton undoButton, out ToolStripButton redoButton)
Action save, Action showWholeGraph, Action toggleGridSnap, InputActionsContainer actionsContainer,
out ToolStripButton saveButton, out ToolStripButton undoButton, out ToolStripButton redoButton, out ToolStripButton gridSnapButton)
{ {
var editor = window.Editor;
var interfaceOptions = editor.Options.Options.Interface;
var inputOptions = editor.Options.Options.Input; var inputOptions = editor.Options.Options.Input;
var undo = surface.Undo;
// Toolstrip // Toolstrip
saveButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Save64, save).LinkTooltip("Save"); saveButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Save64, window.Save).LinkTooltip("Save");
toolStrip.AddSeparator(); toolStrip.AddSeparator();
undoButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Undo64, undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})"); undoButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Undo64, undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})");
redoButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Redo64, undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})"); redoButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Redo64, undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})");
toolStrip.AddSeparator(); toolStrip.AddSeparator();
toolStrip.AddButton(editor.Icons.Search64, editor.ContentFinding.ShowSearch).LinkTooltip($"Open content search tool ({inputOptions.Search})"); toolStrip.AddButton(editor.Icons.Search64, editor.ContentFinding.ShowSearch).LinkTooltip($"Open content search tool ({inputOptions.Search})");
toolStrip.AddButton(editor.Icons.CenterView64, showWholeGraph).LinkTooltip("Show whole graph"); toolStrip.AddButton(editor.Icons.CenterView64, surface.ShowWholeGraph).LinkTooltip("Show whole graph");
gridSnapButton = (ToolStripButton)toolStrip.AddButton(editor.Icons.Stop64, toggleGridSnap).LinkTooltip("Toggle grid snapping for nodes."); var gridSnapButton = toolStrip.AddButton(editor.Icons.Grid32, surface.ToggleGridSnapping);
gridSnapButton.BackgroundColor = Style.Current.Background; // Default color for grid snap button. gridSnapButton.LinkTooltip("Toggle grid snapping for nodes.");
gridSnapButton.AutoCheck = true;
gridSnapButton.Checked = surface.GridSnappingEnabled = interfaceOptions.SurfaceGridSnapping;
surface.GridSnappingSize = interfaceOptions.SurfaceGridSnappingSize;
// Setup input actions // Setup input actions
actionsContainer.Add(options => options.Undo, undo.PerformUndo); window.InputActions.Add(options => options.Undo, undo.PerformUndo);
actionsContainer.Add(options => options.Redo, undo.PerformRedo); window.InputActions.Add(options => options.Redo, undo.PerformRedo);
actionsContainer.Add(options => options.Search, editor.ContentFinding.ShowSearch); window.InputActions.Add(options => options.Search, editor.ContentFinding.ShowSearch);
}
public static void ToggleSurfaceGridSnap(VisjectSurface surface, ToolStripButton gridSnapButton)
{
surface.GridSnappingEnabled = !surface.GridSnappingEnabled;
if (surface.GridSnappingEnabled)
{
gridSnapButton.BackgroundColor = Style.Current.BackgroundSelected;
}
else
{
gridSnapButton.BackgroundColor = Style.Current.Background;
}
} }
} }
} }

View File

@@ -192,26 +192,19 @@ namespace FlaxEditor.Surface
} }
/// <summary> /// <summary>
/// Round a visject coordinate point to the grid. /// Snaps a coordinate point to the grid.
/// </summary> /// </summary>
/// <param name="point">The point to be rounded.</param> /// <param name="point">The point to be rounded.</param>
/// <param name="ceil">Round to ceiling instead?</param> /// <param name="ceil">Round to ceiling instead?</param>
/// <returns></returns> /// <returns>Rounded coordinate.</returns>
public static Float2 RoundToGrid(Float2 point, bool ceil = false) public Float2 SnapToGrid(Float2 point, bool ceil = false)
{ {
Func<float, float> round = x => float gridSize = GridSnappingSize;
{ Float2 snapped = point.Absolute / gridSize;
double pointGridUnits = Math.Abs((double)x) / GridSize; snapped = ceil ? Float2.Ceil(snapped) : Float2.Floor(snapped);
pointGridUnits = ceil ? Math.Ceiling(pointGridUnits) : Math.Floor(pointGridUnits); snapped.X = (float)Math.CopySign(snapped.X * gridSize, point.X);
snapped.Y = (float)Math.CopySign(snapped.Y * gridSize, point.Y);
return (float)Math.CopySign(pointGridUnits * GridSize, x); return snapped;
};
Float2 pointToRound = point;
pointToRound.X = round(pointToRound.X);
pointToRound.Y = round(pointToRound.Y);
return pointToRound;
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -281,7 +274,8 @@ namespace FlaxEditor.Surface
// Moving // Moving
else if (_isMovingSelection) else if (_isMovingSelection)
{ {
if (!GridSnappingEnabled) var gridSnap = GridSnappingEnabled;
if (!gridSnap)
_gridRoundingDelta = Float2.Zero; // Reset in case user toggled option between frames. _gridRoundingDelta = Float2.Zero; // Reset in case user toggled option between frames.
// Calculate delta (apply view offset) // Calculate delta (apply view offset)
@@ -291,25 +285,23 @@ namespace FlaxEditor.Surface
var deltaLengthSquared = delta.LengthSquared; var deltaLengthSquared = delta.LengthSquared;
delta /= _targetScale; delta /= _targetScale;
if ((!GridSnappingEnabled || Math.Abs(delta.X) >= GridSize || (Math.Abs(delta.Y) >= GridSize)) if ((!gridSnap || Mathf.Abs(delta.X) >= GridSnappingSize || (Mathf.Abs(delta.Y) >= GridSnappingSize))
&& deltaLengthSquared > 0.01f) && deltaLengthSquared > 0.01f)
{ {
if (GridSnappingEnabled) if (gridSnap)
{ {
Float2 unroundedDelta = delta; Float2 unroundedDelta = delta;
delta = SnapToGrid(unroundedDelta);
delta = RoundToGrid(unroundedDelta);
_gridRoundingDelta = (unroundedDelta - delta) * _targetScale; // Standardize unit of the rounding delta, in case user zooms between node movements. _gridRoundingDelta = (unroundedDelta - delta) * _targetScale; // Standardize unit of the rounding delta, in case user zooms between node movements.
} }
foreach (var node in _movingNodes) foreach (var node in _movingNodes)
{ {
if (GridSnappingEnabled) if (gridSnap)
{ {
Float2 unroundedLocation = node.Location; Float2 unroundedLocation = node.Location;
node.Location = RoundToGrid(unroundedLocation); node.Location = SnapToGrid(unroundedLocation);
} }
node.Location += delta; node.Location += delta;
} }

View File

@@ -34,18 +34,26 @@ namespace FlaxEditor.Surface
/// <summary> /// <summary>
/// Is grid snapping enabled for this surface? /// Is grid snapping enabled for this surface?
/// </summary> /// </summary>
public bool GridSnappingEnabled = false; public bool GridSnappingEnabled
{
get => _gridSnappingEnabled;
set
{
_gridSnappingEnabled = value;
_gridRoundingDelta = Float2.Zero;
}
}
/// <summary> /// <summary>
/// The size of the snapping grid. /// The size of the snapping grid.
/// </summary> /// </summary>
public static readonly float GridSize = 20f; public float GridSnappingSize = 20f;
private float _targetScale = 1.0f; private float _targetScale = 1.0f;
private float _moveViewWithMouseDragSpeed = 1.0f; private float _moveViewWithMouseDragSpeed = 1.0f;
private bool _canEdit = true; private bool _canEdit = true;
private readonly bool _supportsDebugging; private readonly bool _supportsDebugging;
private bool _isReleasing; private bool _isReleasing, _gridSnappingEnabled;
private VisjectCM _activeVisjectCM; private VisjectCM _activeVisjectCM;
private GroupArchetype _customNodesGroup; private GroupArchetype _customNodesGroup;
private List<NodeArchetype> _customNodes; private List<NodeArchetype> _customNodes;
@@ -642,6 +650,11 @@ namespace FlaxEditor.Surface
SelectionChanged?.Invoke(); SelectionChanged?.Invoke();
} }
internal void ToggleGridSnapping()
{
GridSnappingEnabled = !GridSnappingEnabled;
}
/// <summary> /// <summary>
/// Selects all the nodes. /// Selects all the nodes.
/// </summary> /// </summary>

View File

@@ -891,10 +891,21 @@ namespace FlaxEditor.Surface
/// </summary> /// </summary>
protected Tabs _tabs; protected Tabs _tabs;
private readonly ToolStripButton _saveButton; /// <summary>
private readonly ToolStripButton _undoButton; /// Save button on a toolstrip.
private readonly ToolStripButton _redoButton; /// </summary>
private readonly ToolStripButton _gridSnapButton; protected ToolStripButton _saveButton;
/// <summary>
/// Undo button on a toolstrip.
/// </summary>
protected ToolStripButton _undoButton;
/// <summary>
/// Redo button on a toolstrip.
/// </summary>
protected ToolStripButton _redoButton;
private bool _showWholeGraphOnLoad = true; private bool _showWholeGraphOnLoad = true;
/// <summary> /// <summary>
@@ -951,8 +962,6 @@ namespace FlaxEditor.Surface
protected VisjectSurfaceWindow(Editor editor, AssetItem item, bool useTabs = false) protected VisjectSurfaceWindow(Editor editor, AssetItem item, bool useTabs = false)
: base(editor, item) : base(editor, item)
{ {
var inputOptions = Editor.Options.Options.Input;
// Undo // Undo
_undo = new FlaxEditor.Undo(); _undo = new FlaxEditor.Undo();
_undo.UndoDone += OnUndoRedo; _undo.UndoDone += OnUndoRedo;
@@ -999,10 +1008,6 @@ namespace FlaxEditor.Surface
_propertiesEditor.Panel.Parent = _split2.Panel2; _propertiesEditor.Panel.Parent = _split2.Panel2;
} }
_propertiesEditor.Modified += OnPropertyEdited; _propertiesEditor.Modified += OnPropertyEdited;
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo,
Save, ShowWholeGraph, ToggleGridSnap, InputActions,
out _saveButton, out _undoButton, out _redoButton, out _gridSnapButton);
} }
private void OnUndoRedo(IUndoAction action) private void OnUndoRedo(IUndoAction action)
@@ -1041,11 +1046,6 @@ namespace FlaxEditor.Surface
_surface.ShowWholeGraph(); _surface.ShowWholeGraph();
} }
private void ToggleGridSnap()
{
SurfaceUtils.ToggleSurfaceGridSnap(_surface, _gridSnapButton);
}
/// <summary> /// <summary>
/// Refreshes temporary asset to see changes live when editing the surface. /// Refreshes temporary asset to see changes live when editing the surface.
/// </summary> /// </summary>

View File

@@ -206,6 +206,7 @@ namespace FlaxEditor.Windows.Assets
_surface.ContextChanged += OnSurfaceContextChanged; _surface.ContextChanged += OnSurfaceContextChanged;
// Toolstrip // Toolstrip
SurfaceUtils.PerformCommonSetup(this, _toolstrip, _surface, out _saveButton, out _undoButton, out _redoButton);
_showNodesButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Bone64, () => _preview.ShowNodes = !_preview.ShowNodes).LinkTooltip("Show animated model nodes debug view"); _showNodesButton = (ToolStripButton)_toolstrip.AddButton(editor.Icons.Bone64, () => _preview.ShowNodes = !_preview.ShowNodes).LinkTooltip("Show animated model nodes debug view");
_toolstrip.AddSeparator(); _toolstrip.AddSeparator();
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/animation/anim-graph/index.html")).LinkTooltip("See documentation to learn more"); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/animation/anim-graph/index.html")).LinkTooltip("See documentation to learn more");

View File

@@ -172,13 +172,8 @@ namespace FlaxEditor.Windows.Assets
_knowledgePropertiesEditor.Panel.Parent = _split2.Panel2; _knowledgePropertiesEditor.Panel.Parent = _split2.Panel2;
// Toolstrip // Toolstrip
_saveButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Save64, Save).LinkTooltip("Save"); SurfaceUtils.PerformCommonSetup(this, _toolstrip, _surface, out _saveButton, out _undoButton, out _redoButton);
_toolstrip.AddSeparator(); _toolstrip.AddSeparator();
_undoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Undo64, _undo.PerformUndo).LinkTooltip($"Undo ({inputOptions.Undo})");
_redoButton = (ToolStripButton)_toolstrip.AddButton(Editor.Icons.Redo64, _undo.PerformRedo).LinkTooltip($"Redo ({inputOptions.Redo})");
_toolstrip.AddSeparator();
_toolstrip.AddButton(Editor.Icons.Search64, Editor.ContentFinding.ShowSearch).LinkTooltip($"Open content search tool ({inputOptions.Search})");
_toolstrip.AddButton(editor.Icons.CenterView64, _surface.ShowWholeGraph).LinkTooltip("Show whole graph");
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/scripting/ai/behavior-trees/index.html")).LinkTooltip("See documentation to learn more"); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/scripting/ai/behavior-trees/index.html")).LinkTooltip("See documentation to learn more");
// Debug behavior picker // Debug behavior picker
@@ -206,11 +201,6 @@ namespace FlaxEditor.Windows.Assets
_behaviorPicker.CheckValid = OnBehaviorPickerCheckValid; _behaviorPicker.CheckValid = OnBehaviorPickerCheckValid;
_behaviorPicker.ValueChanged += OnBehaviorPickerValueChanged; _behaviorPicker.ValueChanged += OnBehaviorPickerValueChanged;
// Setup input actions
InputActions.Add(options => options.Undo, _undo.PerformUndo);
InputActions.Add(options => options.Redo, _undo.PerformRedo);
InputActions.Add(options => options.Search, Editor.ContentFinding.ShowSearch);
SetCanEdit(!Editor.IsPlayMode); SetCanEdit(!Editor.IsPlayMode);
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin; ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
} }

View File

@@ -257,8 +257,9 @@ namespace FlaxEditor.Windows.Assets
}; };
// Toolstrip // Toolstrip
_toolstrip.AddSeparator(); SurfaceUtils.PerformCommonSetup(this, _toolstrip, _surface, out _saveButton, out _undoButton, out _redoButton);
_toolstrip.AddButton(editor.Icons.Code64, ShowSourceCode).LinkTooltip("Show generated shader source code"); _toolstrip.AddButton(editor.Icons.Code64, ShowSourceCode).LinkTooltip("Show generated shader source code");
_toolstrip.AddSeparator();
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/graphics/materials/index.html")).LinkTooltip("See documentation to learn more"); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/graphics/materials/index.html")).LinkTooltip("See documentation to learn more");
} }

View File

@@ -141,8 +141,9 @@ namespace FlaxEditor.Windows.Assets
}; };
// Toolstrip // Toolstrip
_toolstrip.AddSeparator(); SurfaceUtils.PerformCommonSetup(this, _toolstrip, _surface, out _saveButton, out _undoButton, out _redoButton);
_toolstrip.AddButton(editor.Icons.Code64, ShowSourceCode).LinkTooltip("Show generated shader source code"); _toolstrip.AddButton(editor.Icons.Code64, ShowSourceCode).LinkTooltip("Show generated shader source code");
_toolstrip.AddSeparator();
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/particles/index.html")).LinkTooltip("See documentation to learn more"); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/particles/index.html")).LinkTooltip("See documentation to learn more");
} }

View File

@@ -30,7 +30,6 @@ namespace FlaxEditor.Windows.Assets
private readonly ToolStripButton _saveButton; private readonly ToolStripButton _saveButton;
private readonly ToolStripButton _undoButton; private readonly ToolStripButton _undoButton;
private readonly ToolStripButton _redoButton; private readonly ToolStripButton _redoButton;
private readonly ToolStripButton _gridSnapButton;
private bool _showWholeGraphOnLoad = true; private bool _showWholeGraphOnLoad = true;
/// <summary> /// <summary>
@@ -71,9 +70,7 @@ namespace FlaxEditor.Windows.Assets
_undo.ActionDone += OnUndoRedo; _undo.ActionDone += OnUndoRedo;
// Toolstrip // Toolstrip
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo, SurfaceUtils.PerformCommonSetup(this, _toolstrip, _surface, out _saveButton, out _undoButton, out _redoButton);
Save, ShowWholeGraph, ToggleGridSnap, InputActions,
out _saveButton, out _undoButton, out _redoButton, out _gridSnapButton);
// Panel // Panel
_panel = new Panel(ScrollBars.None) _panel = new Panel(ScrollBars.None)
@@ -98,11 +95,6 @@ namespace FlaxEditor.Windows.Assets
_surface.ShowWholeGraph(); _surface.ShowWholeGraph();
} }
private void ToggleGridSnap()
{
SurfaceUtils.ToggleSurfaceGridSnap(_surface, _gridSnapButton);
}
/// <summary> /// <summary>
/// Refreshes temporary asset to see changes live when editing the surface. /// Refreshes temporary asset to see changes live when editing the surface.
/// </summary> /// </summary>

View File

@@ -533,7 +533,6 @@ namespace FlaxEditor.Windows.Assets
private readonly ToolStripButton _saveButton; private readonly ToolStripButton _saveButton;
private readonly ToolStripButton _undoButton; private readonly ToolStripButton _undoButton;
private readonly ToolStripButton _redoButton; private readonly ToolStripButton _redoButton;
private readonly ToolStripButton _gridSnapButton;
private Control[] _debugToolstripControls; private Control[] _debugToolstripControls;
private bool _showWholeGraphOnLoad = true; private bool _showWholeGraphOnLoad = true;
private bool _tmpAssetIsDirty; private bool _tmpAssetIsDirty;
@@ -598,11 +597,7 @@ namespace FlaxEditor.Windows.Assets
_propertiesEditor.Select(_properties); _propertiesEditor.Select(_properties);
// Toolstrip // Toolstrip
SurfaceUtils.VisjectCommonToolstripSetup(editor, _toolstrip, _undo, SurfaceUtils.PerformCommonSetup(this, _toolstrip, _surface, out _saveButton, out _undoButton, out _redoButton);
Save, ShowWholeGraph, ToggleGridSnap, InputActions,
out _saveButton, out _undoButton, out _redoButton, out _gridSnapButton);
// The rest of the toolstrip
_toolstrip.AddSeparator(); _toolstrip.AddSeparator();
_toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/scripting/visual/index.html")).LinkTooltip("See documentation to learn more"); _toolstrip.AddButton(editor.Icons.Docs64, () => Platform.OpenUrl(Utilities.Constants.DocsUrl + "manual/scripting/visual/index.html")).LinkTooltip("See documentation to learn more");
_debugToolstripControls = new[] _debugToolstripControls = new[]
@@ -683,11 +678,6 @@ namespace FlaxEditor.Windows.Assets
_surface.ShowWholeGraph(); _surface.ShowWholeGraph();
} }
private void ToggleGridSnap()
{
SurfaceUtils.ToggleSurfaceGridSnap(_surface, _gridSnapButton);
}
/// <summary> /// <summary>
/// Refreshes temporary asset to see changes live when editing the surface. /// Refreshes temporary asset to see changes live when editing the surface.
/// </summary> /// </summary>

View File

@@ -865,6 +865,16 @@ namespace FlaxEngine
return new Float2(Mathf.Ceil(v.X), Mathf.Ceil(v.Y)); return new Float2(Mathf.Ceil(v.X), Mathf.Ceil(v.Y));
} }
/// <summary>
/// Returns the vector with components containing the smallest integer smaller to or equal to the original value.
/// </summary>
/// <param name="v">The value.</param>
/// <returns>The result.</returns>
public static Float2 Floor(Float2 v)
{
return new Float2(Mathf.Floor(v.X), Mathf.Floor(v.Y));
}
/// <summary> /// <summary>
/// Breaks the components of the vector into an integral and a fractional part. Returns vector made of fractional parts. /// Breaks the components of the vector into an integral and a fractional part. Returns vector made of fractional parts.
/// </summary> /// </summary>