Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-10-27 11:01:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-10-27 16:24:52 +0300
commitaea7e555221e071e65fe76eb9571198622bbc547 (patch)
treec63b01d327693cfa82a1d0b6ba3b7f675593df45 /source/blender/editors
parent2a709c82c369a8b87592156bf1afc0222d44a778 (diff)
WM: de-duplicate cursor motion checks for selection picking
Replace local static mouse coordinate storage with a single function. also resolve inconsistencies. - Edit-mesh selection used equality check (ignoring `U.move_threshold`). - Motion to clear tooltips checked the value without scaling by the DPI. Also prevent the unlikely case of the previous motion check matching a different area by resetting the value when the active region changes.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/armature/armature_select.c6
-rw-r--r--source/blender/editors/mesh/editmesh_select.c8
-rw-r--r--source/blender/editors/screen/screen_edit.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c9
4 files changed, 10 insertions, 17 deletions
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index bd799c00373..937385f9ffa 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -673,11 +673,7 @@ static EditBone *get_nearest_editbonepoint(
}
if (use_cycle) {
- static int last_mval[2] = {-100, -100};
- if ((len_manhattan_v2v2_int(vc->mval, last_mval) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) == 0) {
- use_cycle = false;
- }
- copy_v2_v2_int(last_mval, vc->mval);
+ use_cycle = !WM_cursor_test_motion_and_update(vc->mval);
}
const bool do_nearest = !(XRAY_ACTIVE(vc->v3d) || use_cycle);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 2fcf8fa6f8f..e0768bcff24 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -884,9 +884,8 @@ static bool unified_findnearest(ViewContext *vc,
BMFace **r_efa)
{
BMEditMesh *em = vc->em;
- static short mval_prev[2] = {-1, -1};
- /* only cycle while the mouse remains still */
- const bool use_cycle = ((mval_prev[0] == vc->mval[0]) && (mval_prev[1] == vc->mval[1]));
+
+ const bool use_cycle = !WM_cursor_test_motion_and_update(vc->mval);
const float dist_init = ED_view3d_select_dist_px();
/* since edges select lines, we give dots advantage of ~20 pix */
const float dist_margin = (dist_init / 2);
@@ -988,9 +987,6 @@ static bool unified_findnearest(ViewContext *vc,
}
}
- mval_prev[0] = vc->mval[0];
- mval_prev[1] = vc->mval[1];
-
/* Only one element type will be non-null. */
BLI_assert(((hit.v.ele != NULL) + (hit.e.ele != NULL) + (hit.f.ele != NULL)) <= 1);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 841792d5f2d..fa0cfd16817 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -935,6 +935,10 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2])
}
}
}
+
+ /* Ensure test-motion values are never shared between regions. */
+ const bool use_cycle = !WM_cursor_test_motion_and_update((const int[2]){-1, -1});
+ UNUSED_VARS(use_cycle);
}
/* Cursors, for time being set always on edges,
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 07f1f8a753c..18820039c7f 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -2047,19 +2047,16 @@ static int mixed_bones_object_selectbuffer_extended(ViewContext *vc,
bool enumerate,
bool *r_do_nearest)
{
- static int last_mval[2] = {-100, -100};
bool do_nearest = false;
View3D *v3d = vc->v3d;
/* define if we use solid nearest select or not */
if (use_cycle) {
+ /* Update the coordinates (even if the return value isn't used). */
+ const bool has_motion = WM_cursor_test_motion_and_update(mval);
if (!XRAY_ACTIVE(v3d)) {
- do_nearest = true;
- if (len_manhattan_v2v2_int(mval, last_mval) <= WM_EVENT_CURSOR_MOTION_THRESHOLD) {
- do_nearest = false;
- }
+ do_nearest = has_motion;
}
- copy_v2_v2_int(last_mval, mval);
}
else {
if (!XRAY_ACTIVE(v3d)) {