From d5064f14f674812280507abc2421bd0e22239705 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Thu, 2 Jan 2025 12:11:16 +0100 Subject: [PATCH 1/3] iss-1897 - Fix view rotation effects affects various view handles The code getViewScaleInverse assumes the m11 value is a scaling matrix but that's not guaranteed! We see the problem occur when the view has been rotated, which changes the matrix type so that it's no longer a pure scale factor. The fix is to create a new scaling matrix from the mScaling property and inverse that instead. --- core_lib/src/interface/editor.cpp | 2 +- core_lib/src/interface/scribblearea.cpp | 2 +- core_lib/src/managers/viewmanager.cpp | 4 ++-- core_lib/src/managers/viewmanager.h | 8 +++++++- core_lib/src/tool/cameratool.cpp | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core_lib/src/interface/editor.cpp b/core_lib/src/interface/editor.cpp index d5aabb9ac..8c3ceb0de 100644 --- a/core_lib/src/interface/editor.cpp +++ b/core_lib/src/interface/editor.cpp @@ -436,7 +436,7 @@ LayerVisibility Editor::layerVisibility() qreal Editor::viewScaleInversed() { - return view()->getViewScaleInverse(); + return view()->getScaleInversed(); } void Editor::increaseLayerVisibilityIndex() diff --git a/core_lib/src/interface/scribblearea.cpp b/core_lib/src/interface/scribblearea.cpp index 26046470e..64492b89a 100644 --- a/core_lib/src/interface/scribblearea.cpp +++ b/core_lib/src/interface/scribblearea.cpp @@ -1080,7 +1080,7 @@ void ScribbleArea::prepCameraPainter(int frame) mEditor->playback()->isPlaying(), mLayerVisibility, mPrefs->getFloat(SETTING::LAYER_VISIBILITY_THRESHOLD), - mEditor->view()->getViewScaleInverse()); + mEditor->view()->getScaleInversed()); OnionSkinPainterOptions onionSkinOptions; onionSkinOptions.enabledWhilePlaying = mPrefs->getInt(SETTING::ONION_WHILE_PLAYBACK); diff --git a/core_lib/src/managers/viewmanager.cpp b/core_lib/src/managers/viewmanager.cpp index 9b85848ea..0807a3e14 100644 --- a/core_lib/src/managers/viewmanager.cpp +++ b/core_lib/src/managers/viewmanager.cpp @@ -108,9 +108,9 @@ QTransform ViewManager::getViewInverse() const return mViewCanvasInverse; } -qreal ViewManager::getViewScaleInverse() const +qreal ViewManager::getScaleInversed() const { - return mViewCanvasInverse.m11(); + return QTransform::fromScale(mScaling, mScaling).inverted().m11(); } void ViewManager::updateViewTransforms() diff --git a/core_lib/src/managers/viewmanager.h b/core_lib/src/managers/viewmanager.h index 1c0009c4d..269b6afc0 100644 --- a/core_lib/src/managers/viewmanager.h +++ b/core_lib/src/managers/viewmanager.h @@ -36,7 +36,13 @@ class ViewManager : public BaseManager QTransform getView() const; QTransform getViewInverse() const; - qreal getViewScaleInverse() const; + + /** + * Creates a scaling matrix based on the current view scale and returns the inverted value + * @return The inverted scale value + */ + qreal getScaleInversed() const; + void resetView(); QPointF mapCanvasToScreen(QPointF p) const; diff --git a/core_lib/src/tool/cameratool.cpp b/core_lib/src/tool/cameratool.cpp index e0d1045b8..5b5a26823 100644 --- a/core_lib/src/tool/cameratool.cpp +++ b/core_lib/src/tool/cameratool.cpp @@ -81,7 +81,7 @@ void CameraTool::updateUIAssists(const Layer* layer) Camera* cam = camLayer->getLastCameraAtFrame(mEditor->currentFrame(), 0); if (cam) { - mRotationHandlePoint = localRotationHandlePoint(cameraRect.topLeft(), localCamT, cam->scaling(), mEditor->view()->getViewScaleInverse()); + mRotationHandlePoint = localRotationHandlePoint(cameraRect.topLeft(), localCamT, cam->scaling(), mEditor->view()->getScaleInversed()); } } From e0133aa95555bce20058854f59fd905bb21c556b Mon Sep 17 00:00:00 2001 From: MrStevns Date: Thu, 2 Jan 2025 12:21:25 +0100 Subject: [PATCH 2/3] Update changelog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index ea550e159..6674a67b6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -18,6 +18,7 @@ + Avoid updating width/feather sliders for tools that don’t use them [cce3107](https://github.com/pencil2d/pencil/commit/cce31079c871fcc04e957c44d5c6e65990f635f1) + Fix fill misbehaving when drawing was partly outside border [#1865](https://github.com/pencil2d/pencil/pull/1865) + Fix clearing selection with the delete shortcut [#1892](https://github.com/pencil2d/pencil/pull/1892) ++ Fix camera handles not being draggable at 90 deg [#1897](https://github.com/pencil2d/pencil/issues/1897) ## Pencil2D v0.7.0 - 12 July 2024 From aee3c381a60837fd561363ebfbec59d924988f84 Mon Sep 17 00:00:00 2001 From: MrStevns Date: Thu, 2 Jan 2025 14:10:52 +0100 Subject: [PATCH 3/3] Simplify the logic --- core_lib/src/managers/viewmanager.cpp | 2 +- core_lib/src/managers/viewmanager.h | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/core_lib/src/managers/viewmanager.cpp b/core_lib/src/managers/viewmanager.cpp index 0807a3e14..d4b7834e5 100644 --- a/core_lib/src/managers/viewmanager.cpp +++ b/core_lib/src/managers/viewmanager.cpp @@ -110,7 +110,7 @@ QTransform ViewManager::getViewInverse() const qreal ViewManager::getScaleInversed() const { - return QTransform::fromScale(mScaling, mScaling).inverted().m11(); + return 1. / mScaling; } void ViewManager::updateViewTransforms() diff --git a/core_lib/src/managers/viewmanager.h b/core_lib/src/managers/viewmanager.h index 269b6afc0..7b7b8ff8e 100644 --- a/core_lib/src/managers/viewmanager.h +++ b/core_lib/src/managers/viewmanager.h @@ -37,10 +37,7 @@ class ViewManager : public BaseManager QTransform getView() const; QTransform getViewInverse() const; - /** - * Creates a scaling matrix based on the current view scale and returns the inverted value - * @return The inverted scale value - */ + /** @return The inverted scale value */ qreal getScaleInversed() const; void resetView();