[Bf-blender-cvs] [0d07cfd9405] blender-v2.93-release: Fix/Workaround T87511: snap gizmo flickers on Ctrl-Drag

Campbell Barton noreply at git.blender.org
Fri Apr 30 15:12:21 CEST 2021


Commit: 0d07cfd9405464e45186c3c075f255ff519f1d24
Author: Campbell Barton
Date:   Fri Apr 30 23:09:26 2021 +1000
Branches: blender-v2.93-release
https://developer.blender.org/rB0d07cfd9405464e45186c3c075f255ff519f1d24

Fix/Workaround T87511: snap gizmo flickers on Ctrl-Drag

Hack to bypass drag events, eventually the gizmo API
should support this use case without hacks.

===================================================================

M	source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c

===================================================================

diff --git a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
index cd7d0f5fb4c..3cff07dde3f 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/snap3d_gizmo.c
@@ -609,12 +609,23 @@ static int snap_gizmo_test_select(bContext *C, wmGizmo *gz, const int mval[2])
 {
   SnapGizmo3D *snap_gizmo = (SnapGizmo3D *)gz;
   wmWindowManager *wm = CTX_wm_manager(C);
+  ARegion *region = CTX_wm_region(C);
+
+  /* FIXME: this hack is to ignore drag events, otherwise drag events
+   * cause momentary snap gizmo re-positioning at the drag-start location, see: T87511. */
+  if (wm && wm->winactive) {
+    const wmEvent *event = wm->winactive->eventstate;
+    int mval_compare[2] = {event->x - region->winrct.xmin, event->y - region->winrct.ymin};
+    if (!equals_v2v2_int(mval_compare, mval)) {
+      return snap_gizmo->snap_elem ? 0 : -1;
+    }
+  }
+
   if (!eventstate_has_changed(snap_gizmo, wm)) {
     /* Performance, do not update. */
     return snap_gizmo->snap_elem ? 0 : -1;
   }
 
-  ARegion *region = CTX_wm_region(C);
   View3D *v3d = CTX_wm_view3d(C);
   const float mval_fl[2] = {UNPACK2(mval)};
   short snap_elem = ED_gizmotypes_snap_3d_update(



More information about the Bf-blender-cvs mailing list