Fix smart patch tool
Fixes 453024 (thanks to sh_zam for finding the commit that introduced the bug)
distance_impl
had a maximum bound of 1.0f applied in the return value. [0, 1]
I adjusted the upper bound to MAX_DIST to match the documented range [0, MAX_DIST]
Test Plan
I used this image as a base and drew over the black sheep with the smart patch tool:
On a build before this fix, you should see large stripes of the white sky within the filled area. With the fix, you should see just green / grass.
Follow the steps in 451912 to make sure HDR images still don't crash:
STEPS TO REPRODUCE
- Open EXR with 32-bit float/channel RGB/Alpha colour space and sRGB-elle-v2-g10 profile. This is the one i was testing on Krita: https://drive.google.com/file/d/1GiXmsfYesfI3wSQN3wVJU_dg-LF0W3WH/view?usp=sharing
- Add another layer filled with black behind it, purely to make viewing easier
- Select smart patch tool. Not sure if area matters but i was testing a small brush size on the little white dot on the > image's upper part. Trying to use it makes the program crash, sometimes on the first try, sometimes after 2-3 uses of the tool.
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.