diff --git a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs index ff3e5d8dd..0a71189be 100644 --- a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs +++ b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs @@ -128,7 +128,17 @@ namespace FlaxEditor.Surface.Archetypes _mouseMoveStartValues = _editor._node.Surface.Undo != null ? (object[])_editor._node.Values.Clone() : null; } - _editor.SetLocation(_index, _editor.BlendPointPosToBlendSpacePos(Location + location)); + var newLocation = Location + location; + newLocation = _editor.BlendPointPosToBlendSpacePos(newLocation); + if (Root != null && Root.GetKey(KeyboardKeys.Control)) + { + var data0 = (Float4)_editor._node.Values[0]; + var rangeX = new Float2(data0.X, data0.Y); + var rangeY = _editor._is2D ? new Float2(data0.Z, data0.W) : Float2.One; + var grid = new Float2(Mathf.Abs(rangeX.Y - rangeX.X) * 0.01f, Mathf.Abs(rangeY.X - rangeY.Y) * 0.01f); + newLocation = Float2.SnapToGrid(newLocation, grid); + } + _editor.SetLocation(_index, newLocation); } base.OnMouseMove(location); diff --git a/Source/Engine/Core/Math/Float2.cs b/Source/Engine/Core/Math/Float2.cs index ef76cf7cb..9c3909214 100644 --- a/Source/Engine/Core/Math/Float2.cs +++ b/Source/Engine/Core/Math/Float2.cs @@ -1281,8 +1281,8 @@ namespace FlaxEngine /// The position snapped to the grid. public static Float2 SnapToGrid(Float2 pos, Float2 gridSize) { - pos.X = Mathf.Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.Y) * gridSize.X; - pos.Y = Mathf.Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.X) * gridSize.Y; + pos.X = Mathf.Ceil((pos.X - (gridSize.X * 0.5f)) / gridSize.X) * gridSize.X; + pos.Y = Mathf.Ceil((pos.Y - (gridSize.Y * 0.5f)) / gridSize.Y) * gridSize.Y; return pos; }