[Bf-blender-cvs] [73098d2ca5c] master: Gizmo: improve 2D arrow select detection
Campbell Barton
noreply at git.blender.org
Thu Jan 9 02:48:47 CET 2020
Commit: 73098d2ca5c047542fcf6487ee946cb3b50e9683
Author: Campbell Barton
Date: Thu Jan 9 12:40:24 2020 +1100
Branches: master
https://developer.blender.org/rB73098d2ca5c047542fcf6487ee946cb3b50e9683
Gizmo: improve 2D arrow select detection
Fixes issue where UV transform circle was being masked by the arrows.
===================================================================
M source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c
===================================================================
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;
}
More information about the Bf-blender-cvs
mailing list