From b8b432234dd458d91eb872c7f3bc224f8564a782 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Fri, 9 Apr 2021 15:32:04 +0900 Subject: [PATCH] fix shift and trace scaling --- toonz/sources/tnztools/shifttracetool.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/toonz/sources/tnztools/shifttracetool.cpp b/toonz/sources/tnztools/shifttracetool.cpp index b295c7e7..b641a3f0 100644 --- a/toonz/sources/tnztools/shifttracetool.cpp +++ b/toonz/sources/tnztools/shifttracetool.cpp @@ -529,15 +529,17 @@ void ShiftTraceTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) { m_oldPos = pos; m_aff[m_ghostIndex] = TTranslation(delta) * m_aff[m_ghostIndex]; } else if (m_gadget == ScaleGadget) { - TAffine aff = getGhostAff(); - TPointD c = aff * m_center[m_ghostIndex]; - TPointD a = m_oldPos - c; - TPointD b = pos - c; + TAffine aff = getGhostAff(); + TPointD c = m_center[m_ghostIndex]; + TPointD a = aff.inv() * m_oldPos - c; + TPointD b = aff.inv() * pos - c; + TPointD imgC = aff * m_center[m_ghostIndex]; + if (e.isShiftPressed()) - m_aff[m_ghostIndex] = m_oldAff * TScale(b.x / a.x, b.y / a.y); + m_aff[m_ghostIndex] = TScale(imgC, b.x / a.x, b.y / a.y) * m_oldAff; else { double scale = std::max(b.x / a.x, b.y / a.y); - m_aff[m_ghostIndex] = m_oldAff * TScale(scale, scale); + m_aff[m_ghostIndex] = TScale(imgC, scale) * m_oldAff; } }