diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-09 04:40:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-09 04:45:58 +0300 |
commit | 73098d2ca5c047542fcf6487ee946cb3b50e9683 (patch) | |
tree | 19f19b1457d080f0b64ed3ca58ed93a8354afb07 /source/blender/editors/gizmo_library/gizmo_types | |
parent | 7ae35a7369df5b3eb0845996d9e1734d2bff80ef (diff) |
Gizmo: improve 2D arrow select detection
Fixes issue where UV transform circle was being masked by the arrows.
Diffstat (limited to 'source/blender/editors/gizmo_library/gizmo_types')
-rw-r--r-- | source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index 22d4a8f2676..a56b4f43e8f 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -239,11 +239,24 @@ static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int m const float mval_fl[2] = {UNPACK2(mval)}; const float arrow_stem_threshold_px = 5 * UI_DPI_FAC; - const float arrow_head_threshold_px = 10 * UI_DPI_FAC; - if (dist_squared_to_line_v2(mval_fl, arrow_start, arrow_end) < SQUARE(arrow_stem_threshold_px) || - len_squared_v2v2(mval_fl, arrow_end) < SQUARE(arrow_head_threshold_px)) { + const float arrow_head_threshold_px = 12 * UI_DPI_FAC; + + /* Distance to arrow head. */ + if (len_squared_v2v2(mval_fl, arrow_end) < SQUARE(arrow_head_threshold_px)) { return 0; } + + /* Distance to arrow stem. */ + float co_isect[2]; + const float lambda = closest_to_line_v2(co_isect, mval_fl, arrow_start, arrow_end); + /* Clamp inside the line, to avoid overlapping with other gizmos, + * especially around the start of the arrow. */ + if (lambda >= 0.0 && lambda <= 1.0) { + if (len_squared_v2v2(mval_fl, co_isect) < SQUARE(arrow_stem_threshold_px)) { + return 0; + } + } + return -1; } |