diff --git a/dev/Code/Sandbox/Editor/VegetationTool.cpp b/dev/Code/Sandbox/Editor/VegetationTool.cpp index c8105b21c9..abf89b5bce 100644 --- a/dev/Code/Sandbox/Editor/VegetationTool.cpp +++ b/dev/Code/Sandbox/Editor/VegetationTool.cpp @@ -305,6 +305,10 @@ bool CVegetationTool::OnLButtonUp(CViewport* view, UINT nFlags, const QPoint& po // Reset selected region. view->ResetSelectionRegion(); + + // reset aggregated manipulator offset + m_manipulatorOffset = ZERO; + return true; } @@ -1406,8 +1410,13 @@ void CVegetationTool::OnManipulatorDrag(CViewport* view, ITransformManipulator* // get current axis constrains. if (editMode == eEditModeMove) { + // The offset value passed to this function is the value since the manipulator was started dragging (i.e. when LMB is pressed) + // but MoveSelected will apply this offset to the current position. We compute the desired offset based on previous applied manipulator drags + Vec3 offsetThisDrag = value - m_manipulatorOffset; + m_manipulatorOffset = value; + GetIEditor()->RestoreUndo(); - MoveSelected(view, value, true); + MoveSelected(view, offsetThisDrag, true); } if (editMode == eEditModeRotate) { diff --git a/dev/Code/Sandbox/Editor/VegetationTool.h b/dev/Code/Sandbox/Editor/VegetationTool.h index af0450db4a..bdd3338284 100644 --- a/dev/Code/Sandbox/Editor/VegetationTool.h +++ b/dev/Code/Sandbox/Editor/VegetationTool.h @@ -109,6 +109,7 @@ class CVegetationTool QPoint m_mousePos; QPoint m_prevMousePos; Vec3 m_pointerPos; + Vec3 m_manipulatorOffset = ZERO; bool m_mouseOverPaintableSurface; static float m_brushRadius;