[Bf-blender-cvs] [475908c0241] transform-navigation-snapsource: Allow navigating while transforming

Germano Cavalcante noreply at git.blender.org
Sat Dec 4 16:51:27 CET 2021


Commit: 475908c02418af9e08a0b0245218aa4931a32804
Author: Germano Cavalcante
Date:   Sat Dec 4 12:36:58 2021 -0300
Branches: transform-navigation-snapsource
https://developer.blender.org/rB475908c02418af9e08a0b0245218aa4931a32804

Allow navigating while transforming

Navigating while transforming is not a new idea:
- https://rightclickselect.com/p/ui/Tqbbbc/allow-navigating-while-transforming (See comments);
- {D1583}
- {T37427}

This feature allows us to be more precise where the transformed element will be placed.

This would avoid, for example, the need for the node editor to automatically update the viewport when a node is transformed.

And with {D9415} navigating while transform becomes a necessity because: how could we move from a point at the bottom of one object to the top of another without being able to rotate the view?

The patch implements this feature as being experimental (See image):
{F11826349, layout=left, width=600}
Because transform's modal keymaps conflict, two (temporary) operators were created to update the keymap and avoid conflicts.
The main solution in the patch was to create the `bool WM_operator_do_navigation(...);` utility that can be used for any operator.

- This patch only affects the transform operators. They are:
 - Translation,
 - Rotation,
 - Resize,
 - Skin Resize,
 - To Sphere,
 - Shear,
 - Bend,
 - Shrink/Fatten,
 - Tilt,
 - Trackball,
 - Push/Pull,
 - Crease,
 - Mirror,
 - Bone Size,
 - Bone Envelope,
 - Bone Envelope Distance,
 - Curve Shrink/Fatten,
 - Mask Shrink/Fatten,
 - Grease Pencil Shrink/Fatten,
 - Bone Roll,
 - Time Translate,
 - Time Slide,
 - Time Scale,
 - Time Extend,
 - Bake Time,
 - Bevel Weight,
 - Align,
 - Edge Slide,
 - Sequence Slide,
 - Grease Pencil Opacity
- This feature affects all editors where transforming is possible (UV, VSE, Graph...)
- The Node editor is the only one that, when canceling, the viewport position is reset
- Navigation is not available when transforming with Release Confirm
- Default modal keymaps need to be edited to avoid conflict (in the patch a temporary operator was implemented to automatically update keymaps)
|Modal Map (Blender):| Conflict: | Current: | New:
|---|---|---|---
| Increase Proportional Influence | VIEW3D_OT_zoom | Wheel Down | Alt Wheel Down
| Decrease Proportional Influence | VIEW3D_OT_zoom | Wheel Up | Alt Wheel Up
| Adjust Proportional Influence | VIEW3D_OT_rotate | Mouse/Trackpad Pan | Alt Mouse/Trackpad Pan
| Increase Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Down | Alt Wheel Down
| Decrease Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Up | Alt Wheel Up
| Automatic Constraint | VIEW3D_OT_rotate | Middle Mouse | Shift Alt Middle Mouse
| Automatic Constraint Plane | VIEW3D_OT_move | Shift Middle Mouse | Shift Ctrl Alt Middle Mouse

|Modal Map (Industry Compatible):| Conflict: | Current: | New:
|---|---|---|---
| Increase Proportional Influence | VIEW3D_OT_zoom | Wheel Down | Shift Alt Wheel Down
| Decrease Proportional Influence | VIEW3D_OT_zoom | Wheel Up | Shift Alt Wheel Up
| Adjust Proportional Influence | VIEW3D_OT_rotate | Mouse/Trackpad Pan | Alt Mouse/Trackpad Pan
| Select Next Edge Slide Edge | VIEW3D_OT_zoom | Alt Wheel Down | Shift Ctrl Alt Wheel Down
| Select Previous Edge Slide Edge | VIEW3D_OT_zoom | Alt Wheel Up | Shift Ctrl Alt Wheel Up
| Increase Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Down | Shift Alt Wheel Down
| Decrease Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Up | Shift Alt Wheel Up

|Modal Map (Blender 27x):| Conflict: | Current: | New:
|---|---|---|---
| Increase Proportional Influence | VIEW3D_OT_zoom | Wheel Down | Alt Wheel Down
| Decrease Proportional Influence | VIEW3D_OT_zoom | Wheel Up | Alt Wheel Up
| Increase Proportional Influence | VIEW3D_OT_view_pan | Shift Wheel Down | Shift Alt Wheel Down
| Decrease Proportional Influence | VIEW3D_OT_view_pan | Shift Wheel Up | Shift Alt Wheel Up
| Adjust Proportional Influence | VIEW3D_OT_rotate | Mouse/Trackpad Pan | Alt Mouse/Trackpad Pan
| Increase Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Down | Alt Wheel Down
| Decrease Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Up | Alt Wheel Up
| Increase Max AutoIK Chain Length | VIEW3D_OT_view_pan | Shift Wheel Down | Shift Alt Wheel Down
| Decrease Max AutoIK Chain Length | VIEW3D_OT_view_pan | Shift Wheel Up | Shift Alt Wheel Up
| Automatic Constraint | VIEW3D_OT_rotate | Middle Mouse | Shift Alt Middle Mouse
| Automatic Constraint Plane | VIEW3D_OT_move | Shift Middle Mouse | Shift Ctrl Alt Middle Mouse

Differential Revision: https://developer.blender.org/D2624

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

M	release/scripts/addons
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_ops.c
M	source/blender/windowmanager/intern/wm_operator_utils.c
M	source/tools

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

diff --git a/release/scripts/addons b/release/scripts/addons
index f2a08d80ccd..4de1bcce5a2 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit f2a08d80ccd3c13af304525778df3905f95bd44d
+Subproject commit 4de1bcce5a2caa31131c40cc19f0a1851c2eb635
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 538baad5490..51167b327d6 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -899,8 +899,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
       t->con.mode |= CON_SELECT;
     }
 
-    copy_v2_v2_int(t->mval, event->mval);
-
     /* Use this for soft redraw. Might cause flicker in object mode */
     // t->redraw |= TREDRAW_SOFT;
     t->redraw |= TREDRAW_HARD;
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 8cb5418825e..b33d6a43f11 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -425,20 +425,43 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
   }
 #endif
 
+  if (event->type == MOUSEMOVE) {
+    /* Call before #tranformViewUpdate. */
+    copy_v2_v2_int(t->mval, event->mval);
+  }
+
+  if (t->flag & T_VIEW_DIRTY) {
+    if (t->spacetype == SPACE_VIEW3D) {
+      RegionView3D *rv3d = t->region->regiondata;
+      if (rv3d->sms) {
+        /* Smooth View in progress. */
+        return OPERATOR_RUNNING_MODAL;
+      }
+    }
+    /* Call before #applyMouseInput. */
+    tranformViewUpdate(t);
+
+    if (t->mouse.precision) {
+      /* WOKARROUND: Navigation operators like #VIEW3D_OT_zoom_border can make some modal events go
+       * unnoticed. */
+      short event_val = event->type == EVT_MODAL_MAP ? event->prev_val : event->val;
+      if (event_val == KM_RELEASE) {
+        t->modifiers &= ~MOD_PRECISION;
+        t->mouse.precision = 0;
+      }
+    }
+  }
+
   /* XXX insert keys are called here, and require context */
   t->context = C;
   exit_code = transformEvent(t, event);
   t->context = NULL;
 
-  if (!(t->flag & T_RELEASE_CONFIRM)) {
+  if ((exit_code == OPERATOR_PASS_THROUGH) && !(t->flag & T_RELEASE_CONFIRM) &&
+      WM_operator_do_navigation(C, op, event)) {
     /* Allow navigation while transforming */
-    if ((exit_code == OPERATOR_PASS_THROUGH) && WM_operator_do_navigation(C, op, event)) {
-      t->flag |= T_VIEW_DIRTY;
-      return OPERATOR_RUNNING_MODAL;
-    }
-    else if (t->flag & T_VIEW_DIRTY) {
-      tranformViewUpdate(t);
-    }
+    t->flag |= T_VIEW_DIRTY;
+    return OPERATOR_RUNNING_MODAL;
   }
 
   /* XXX, workaround: active needs to be calculated before transforming,
@@ -1368,7 +1391,7 @@ static void TRANSFORM_OT_from_gizmo(struct wmOperatorType *ot)
 
 static wmKeyMapItem **navigation_keymaps(bContext *C, int *r_kmi_len)
 {
-  wmKeyMapItem *km_items[70];
+  wmKeyMapItem *km_items[80];
   int kmi_len = 0;
 
   const char *op_names[] = {
@@ -1378,6 +1401,8 @@ static wmKeyMapItem **navigation_keymaps(bContext *C, int *r_kmi_len)
       "VIEW3D_OT_move",
       "VIEW3D_OT_view_pan",
       "VIEW3D_OT_dolly",
+      "VIEW3D_OT_view_center_pick",
+      "VIEW3D_OT_zoom_border",
       //"VIEW3D_OT_view_orbit",
       "VIEW3D_OT_view_roll",
 #ifdef WITH_INPUT_NDOF
@@ -1397,6 +1422,7 @@ static wmKeyMapItem **navigation_keymaps(bContext *C, int *r_kmi_len)
       "VIEW2D_OT_pan",
       "VIEW2D_OT_zoom_in",
       "VIEW2D_OT_zoom_out",
+      "VIEW2D_OT_zoom_border",
 #ifdef WITH_INPUT_NDOF
       "VIEW2D_OT_ndof",
 #endif
@@ -1510,20 +1536,24 @@ static int modalkeymap_update_invoke(bContext *C, wmOperator *op, const wmEvent
   int kmi_navigate_len, kmi_modals_len, kmi_modals_new_len;
   wmKeyMapItem **kmi_navigate, **kmi_modals, **kmi_modals_new;
   kmi_navigate = navigation_keymaps(C, &kmi_navigate_len);
-  kmi_modals_len = BLI_listbase_count(&modalmap->items);
+  kmi_modals_len = BLI_listbase_count(&modalmap->items) - 3;
   kmi_modals = BLI_array_alloca(kmi_modals, kmi_modals_len);
   kmi_modals_new = BLI_array_alloca(kmi_modals_new, kmi_modals_len);
   kmi_modals_new_len = 0;
 
-  int i;
-  LISTBASE_FOREACH_INDEX (wmKeyMapItem *, kmi_modal, &modalmap->items, i) {
-    kmi_modals[i] = kmi_modal;
+  kmi_modals_len = 0;
+  LISTBASE_FOREACH (wmKeyMapItem *, kmi_modal, &modalmap->items) {
+    if (ELEM(kmi_modal->propvalue, TFM_MODAL_AXIS_X, TFM_MODAL_AXIS_Y, TFM_MODAL_AXIS_Z)) {
+      /* Do not change these keyitems. */
+      continue;
+    }
+    kmi_modals[kmi_modals_len++] = kmi_modal;
   }
 
   struct KMConflict conflicts[CONFLICT_MAX_LEN];
   int conflicts_len = 0;
 
-  for (i = 0; i < kmi_modals_len; i++) {
+  for (int i = 0; i < kmi_modals_len; i++) {
     wmKeyMapItem *kmi_modal = kmi_modals[i];
     if (kmi_modal->flag & KMI_INACTIVE) {
       continue;
@@ -1564,12 +1594,15 @@ static int modalkeymap_update_invoke(bContext *C, wmOperator *op, const wmEvent
       BLI_snprintf(conflict->descr,
                    LABEL_LINE_SIZE,
                    "\"%s\" will change from '%s' to '%s' (as it conflicts with \"%s\")",
-                   TIP_(name),
+                   IFACE_(name),
                    descriptor,
                    descriptor_new,
                    kmi->idname);
 
+#if DEBUG
       printf("%s\n", conflict->descr);
+#endif
+
       if (conflicts_len == CONFLICT_MAX_LEN) {
         BLI_assert(false);
         break;
@@ -1672,7 +1705,7 @@ static int modalkeymap_restore_invoke(bContext *C, wmOperator *op, const wmEvent
       BLI_snprintf(conflict->descr,
                    LABEL_LINE_SIZE,
                    "\"%s\" will be restored from '%s' to '%s'",
-                   TIP_(name),
+                   IFACE_(name),
                    descriptor,
                    descriptor_new);
 
diff --git a/source/blender/windowmanager/intern/wm_operator_utils.c b/source/blender/windowmanager/intern/wm_operator_utils.c
index f0ff18b89b6..b540adb8875 100644
--- a/source/blender/windowmanager/intern/wm_operator_utils.c
+++ b/source/blender/windowmanager/intern/wm_operator_utils.c
@@ -375,6 +375,8 @@ bool WM_operator_do_navigation(bContext *C, wmOperator *op, const wmEvent *event
       "VIEW3D_OT_move",
       "VIEW3D_OT_view_pan",
       "VIEW3D_OT_dolly",
+      "VIEW3D_OT_view_center_pick",
+      "VIEW3D_OT_zoom_border",
       // "VIEW3D_OT_view_orbit",
       "VIEW3D_OT_view_roll",
 #ifdef WITH_INPUT_NDOF
@@ -394,6 +396,7 @@ bool WM_operator_do_navigation(bContext *C, wmOperator *op, const wmEvent *event
       "VIEW2D_OT_pan",
       "VIEW2D_OT_zoom_in",
       "VIEW2D_OT_zoom_out",
+      "VIEW2D_OT_zoom_border",
 #ifdef WITH_INPUT_NDOF
       "VIEW2D_OT_ndof",
 #endif
@@ -402,7 +405,7 @@ bool WM_operator_do_navigation(bContext *C, wmOperator *op, const wmEvent *event
   static struct {
     wmKeyMapItem *kmi;
     wmOperatorType *ot;
-  } kmi_ot[70];
+  } kmi_ot[80];
   static int kmi_ot_len;
 
   /* Lazy initialization (avoids having to allocating a context). */
diff --git a/source/tools b/source/tools
index 2e8c8792488..b22d19e47f4 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 2e8c879248822c8e500ed49d79acc605e5aa75b9
+Subproject commit b22d19e47f4d0353082f3d9f30ee8d244c5266d5



More information about the Bf-blender-cvs mailing list