Make GridSize public.

This commit is contained in:
Menotdan
2023-09-17 18:31:49 -04:00
parent 02d68bc057
commit 83bf68a64f
2 changed files with 8 additions and 4 deletions

View File

@@ -181,8 +181,8 @@ namespace FlaxEditor.Surface
private Float2 RoundToGrid(Float2 point)
{
Float2 pointToRound = point;
pointToRound.X = (float)Math.CopySign(Math.Floor(Math.Abs((double)pointToRound.X) / _gridSize) * _gridSize, pointToRound.X);
pointToRound.Y = (float)Math.CopySign(Math.Floor(Math.Abs((double)pointToRound.Y) / _gridSize) * _gridSize, pointToRound.Y);
pointToRound.X = (float)Math.CopySign(Math.Floor(Math.Abs((double)pointToRound.X) / GridSize) * GridSize, pointToRound.X);
pointToRound.Y = (float)Math.CopySign(Math.Floor(Math.Abs((double)pointToRound.Y) / GridSize) * GridSize, pointToRound.Y);
return pointToRound;
}
@@ -244,7 +244,7 @@ namespace FlaxEditor.Surface
var deltaLengthSquared = delta.LengthSquared;
delta /= _targetScale;
if ((!GridSnappingEnabled || Math.Abs(delta.X) >= _gridSize || (Math.Abs(delta.Y) >= _gridSize))
if ((!GridSnappingEnabled || Math.Abs(delta.X) >= GridSize || (Math.Abs(delta.Y) >= GridSize))
&& deltaLengthSquared > 0.01f)
{
if (GridSnappingEnabled)

View File

@@ -35,7 +35,11 @@ namespace FlaxEditor.Surface
/// </summary>
public bool GridSnappingEnabled = false;
private readonly float _gridSize = 15f;
/// <summary>
/// The size of the snapping grid.
/// </summary>
public static readonly float GridSize = 15f;
private float _targetScale = 1.0f;
private float _moveViewWithMouseDragSpeed = 1.0f;
private bool _canEdit = true;