Fix precision of blend points moving in Multi Blend

This commit is contained in:
Wojtek Figat
2024-04-18 17:22:37 +02:00
parent d8079367fd
commit 4b6b24f4c5

View File

@@ -35,6 +35,7 @@ namespace FlaxEditor.Surface.Archetypes
{ {
private readonly BlendPointsEditor _editor; private readonly BlendPointsEditor _editor;
private readonly int _index; private readonly int _index;
private Float2 _mousePosOffset;
private bool _isMouseDown, _mouseMoved; private bool _isMouseDown, _mouseMoved;
private object[] _mouseMoveStartValues; private object[] _mouseMoveStartValues;
@@ -65,6 +66,7 @@ namespace FlaxEditor.Surface.Archetypes
_editor._node.Surface.AddBatchedUndoAction(new EditNodeValuesAction(_editor._node, _mouseMoveStartValues, true)); _editor._node.Surface.AddBatchedUndoAction(new EditNodeValuesAction(_editor._node, _mouseMoveStartValues, true));
_mouseMoveStartValues = null; _mouseMoveStartValues = null;
} }
_editor._node.Surface.MarkAsEdited();
} }
/// <inheritdoc /> /// <inheritdoc />
@@ -103,6 +105,7 @@ namespace FlaxEditor.Surface.Archetypes
_isMouseDown = true; _isMouseDown = true;
_mouseMoved = false; _mouseMoved = false;
_mouseMoveStartValues = null; _mouseMoveStartValues = null;
_mousePosOffset = -location;
StartMouseCapture(); StartMouseCapture();
return true; return true;
} }
@@ -134,7 +137,7 @@ namespace FlaxEditor.Surface.Archetypes
_mouseMoveStartValues = _editor._node.Surface.Undo != null ? (object[])_editor._node.Values.Clone() : null; _mouseMoveStartValues = _editor._node.Surface.Undo != null ? (object[])_editor._node.Values.Clone() : null;
} }
var newLocation = Location + location; var newLocation = Location + location + _mousePosOffset;
newLocation = _editor.BlendPointPosToBlendSpacePos(newLocation); newLocation = _editor.BlendPointPosToBlendSpacePos(newLocation);
if (Root != null && Root.GetKey(KeyboardKeys.Control)) if (Root != null && Root.GetKey(KeyboardKeys.Control))
{ {
@@ -309,7 +312,6 @@ namespace FlaxEditor.Surface.Archetypes
dataA.Y = Mathf.Clamp(location.Y, ranges.Z, ranges.W); dataA.Y = Mathf.Clamp(location.Y, ranges.Z, ranges.W);
_node.Values[4 + index * 2] = dataA; _node.Values[4 + index * 2] = dataA;
_node.Surface.MarkAsEdited();
_node.UpdateUI(); _node.UpdateUI();
} }