Bug 426949

Summary: Edit raster selection breaks position
Product: krita Reporter: caetano <chameleonscales>
Component: Tools/SelectionAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: dimula73, griffinvalley
Priority: NOR    
Version: 4.4.0-beta1   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Broken edit selection

Description caetano 2020-09-25 09:11:57 UTC
Created attachment 131924 [details]
Broken edit selection

SUMMARY
For raster selections, the Edit Selection transform tool randomly changes the position of your rectangle as you drag a handle, as shown in this video :
https://peertube.mastodon.host/videos/watch/28f13898-c3bf-4fb0-940e-31be945125f3
The effect seems to be more pronounced the more zoomed out you are.

STEPS TO REPRODUCE
1. Create a blank document
2. Pick the Rectangle selection tool
3. Make sure it's set to raster selection and not vector
4. Select a rectangle inside your image
5. Zoom out a bit
6. Click on the menu Select > Edit Selection
6. Drag a corner and move it randomly without releasing the mouse button

OBSERVED RESULT

the opposite corner moves when it should stay still.


SOFTWARE/OS VERSIONS

Both Krita 4.3.0 and 4.4.0 beta1 appimages have this bug
System : Xubuntu 20.04
System's Qt Version (not sure the appimage uses it): 5.12.8
Comment 1 wolthera 2020-09-25 11:30:38 UTC
I can confirm on Krita 5 pre-alpha (git 877573c) on KDE Neon with Qt 5.15.0.
Comment 2 Dmitry Kazakov 2020-10-01 10:30:46 UTC
Git commit e767083bc9e761cc9b83f3b8102bef0fe1d21d1f by Dmitry Kazakov.
Committed on 01/10/2020 at 10:30.
Pushed by dkazakov into branch 'krita/4.3'.

Catch a case when the simplex algorithm converges to a false point

Sometimes the algorithm converges to a false point, even though error
walue is still hight. It makes the transformation bounding box jump
from place to place. Just ignore this transformation if the solution
has not been found.

M  +8    -0    plugins/tools/tool_transform2/kis_free_transform_strategy.cpp
M  +10   -0    plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.cpp
M  +1    -0    plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.h

https://invent.kde.org/graphics/krita/commit/e767083bc9e761cc9b83f3b8102bef0fe1d21d1f
Comment 3 Dmitry Kazakov 2020-10-01 10:30:54 UTC
Git commit cec1b1ea818e995b1d1a146acbafa6e6a84c548c by Dmitry Kazakov.
Committed on 01/10/2020 at 10:30.
Pushed by dkazakov into branch 'krita/4.3'.

Fix small jumps in free transform when the object is mirrored

When the scale crosses the zero value, the algorithm could behave
in a less stable way. To overcome this issue, for the reference value
we shouldn't use any distance term. Instead we should calculate the
expected position for the moved point and pass it to the algorithm
explicitly.

M  +26   -27   plugins/tools/tool_transform2/kis_free_transform_strategy.cpp
M  +27   -17   plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.cpp
M  +2    -2    plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.h

https://invent.kde.org/graphics/krita/commit/cec1b1ea818e995b1d1a146acbafa6e6a84c548c
Comment 4 Dmitry Kazakov 2020-10-01 10:31:12 UTC
Git commit da452ab109c8a32d8d6c606a579233191a70a86d by Dmitry Kazakov.
Committed on 01/10/2020 at 10:30.
Pushed by dkazakov into branch 'master'.

Catch a case when the simplex algorithm converges to a false point

Sometimes the algorithm converges to a false point, even though error
walue is still hight. It makes the transformation bounding box jump
from place to place. Just ignore this transformation if the solution
has not been found.

M  +8    -0    plugins/tools/tool_transform2/kis_free_transform_strategy.cpp
M  +10   -0    plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.cpp
M  +1    -0    plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.h

https://invent.kde.org/graphics/krita/commit/da452ab109c8a32d8d6c606a579233191a70a86d
Comment 5 Dmitry Kazakov 2020-10-01 10:31:20 UTC
Git commit 9509bce98ffc04e64dfd99caf67387d37f784f8d by Dmitry Kazakov.
Committed on 01/10/2020 at 10:30.
Pushed by dkazakov into branch 'master'.

Fix small jumps in free transform when the object is mirrored

When the scale crosses the zero value, the algorithm could behave
in a less stable way. To overcome this issue, for the reference value
we shouldn't use any distance term. Instead we should calculate the
expected position for the moved point and pass it to the algorithm
explicitly.

M  +26   -27   plugins/tools/tool_transform2/kis_free_transform_strategy.cpp
M  +27   -17   plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.cpp
M  +2    -2    plugins/tools/tool_transform2/kis_free_transform_strategy_gsl_helpers.h

https://invent.kde.org/graphics/krita/commit/9509bce98ffc04e64dfd99caf67387d37f784f8d
Comment 6 caetano 2021-01-30 20:20:06 UTC
issue still there in 4.4.2. Should we expect the fix in the next version?