[Bf-blender-cvs] [4faed6f315c] tmp-transform-navigate: Allow navigating while transforming (second solution)

Germano Cavalcante noreply at git.blender.org
Tue Mar 1 14:13:57 CET 2022


Commit: 4faed6f315c12910a698984c4de7250154af1eb4
Author: Germano Cavalcante
Date:   Tue Mar 1 10:00:56 2022 -0300
Branches: tmp-transform-navigate
https://developer.blender.org/rB4faed6f315c12910a698984c4de7250154af1eb4

Allow navigating while transforming (second solution)

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 freedom in transforming an object in closed spaces.

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 ED_view3d_navigation_do(...);` utility that can be used for any operator.

- Currently only 3 navigation operators are supported (more may be added over time):
 - VIEW3D_OT_zoom,
 - VIEW3D_OT_rotate,
 - VIEW3D_OT_move
- This patch only affects the modal transform operators in 3D View. They are:
 - Translation,
 - Rotation,
 - Resize,
 - Skin Resize,
 - To Sphere,
 - Shear,
 - Bend,
 - Shrink/Fatten,
 - Tilt,
 - Trackball,
 - Push/Pull,
 - Crease,
 - Bone Size,
 - Bone Envelope,
 - Bone Envelope Distance,
 - Curve Shrink/Fatten,
 - Grease Pencil Shrink/Fatten,
 - Bone Roll,
 - Bevel Weight,
 - Align,
 - Edge Slide,
 - Sequence Slide,
 - Grease Pencil Opacity
- 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 | Alt Middle Mouse
| Automatic Constraint Plane | VIEW3D_OT_move | Shift Middle Mouse | Shift Alt Middle Mouse

|Modal Map (Industry Compatible):| Conflict: | Current: | New:
|---|---|---|---
| Increase Proportional Influence | VIEW3D_OT_zoom | Wheel Down | Shift Wheel Down
| Decrease Proportional Influence | VIEW3D_OT_zoom | Wheel Up | Shift 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 Alt Wheel Down
| Select Previous Edge Slide Edge | VIEW3D_OT_zoom | Alt Wheel Up | Shift Alt Wheel Up
| Increase Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Down | Shift Wheel Down
| Decrease Max AutoIK Chain Length | VIEW3D_OT_zoom | Wheel Up | Shift 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 | Alt Middle Mouse
| Automatic Constraint Plane | VIEW3D_OT_move | Shift Middle Mouse | Shift Alt Middle Mouse

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

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

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/space_view3d/view3d_navigate.c
M	source/blender/editors/space_view3d/view3d_navigate.h
M	source/blender/editors/space_view3d/view3d_navigate_move.c
M	source/blender/editors/space_view3d/view3d_navigate_rotate.c
M	source/blender/editors/space_view3d/view3d_navigate_zoom.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_convert_node.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_input.c
M	source/blender/editors/transform/transform_ops.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_event_system.c

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index f80ad378b3c..4cec8a1e9b5 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -2262,8 +2262,16 @@ class USERPREF_PT_experimental_new_features(ExperimentalPanel, Panel):
                 ({"property": "use_sculpt_tools_tilt"}, "T82877"),
                 ({"property": "use_extended_asset_browser"}, ("project/view/130/", "Project Page")),
                 ({"property": "use_override_templates"}, ("T73318", "Milestone 4")),
+                ({"property": "use_navigate_while_transform"}, ("T73993", "Milestone 2")),
             ),
         )
+        experimental = context.preferences.experimental
+
+        if experimental.use_navigate_while_transform:
+            split = self.layout.split(factor=0.66)
+            row = split.split()
+            row.operator("transform.modalkeymap_update")
+            row.operator("transform.modalkeymap_restore")
 
 
 class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel):
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index b1435e76eb2..ead3ed34779 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -41,12 +41,15 @@ struct SnapObjectContext;
 struct View3D;
 struct ViewContext;
 struct ViewLayer;
+struct ViewOpsData;
 struct bContext;
 struct bPoseChannel;
 struct bScreen;
 struct rctf;
 struct rcti;
+struct wmEvent;
 struct wmGizmo;
+struct wmKeyMapItem;
 struct wmWindow;
 struct wmWindowManager;
 
@@ -201,6 +204,18 @@ bool ED_view3d_depth_unproject_v3(const struct ARegion *region,
                                   double depth,
                                   float r_location_world[3]);
 
+/* Temporary function that will last as long as the navigation feature during transform is
+ * experimental. */
+void ed_view3d_kmi_navigation_fill_array(struct bContext *C,
+                                         const int array_len_max,
+                                         struct wmKeyMapItem **r_km_items,
+                                         int *r_kmi_len);
+struct ViewOpsData *ED_view3d_navigation_init(struct bContext *C);
+bool ED_view3d_navigation_do(struct bContext *C,
+                             struct ViewOpsData *vod,
+                             const struct wmEvent *event);
+void ED_view3d_navigation_free(struct bContext *C, struct ViewOpsData *vod);
+
 /* Projection */
 #define IS_CLIPPED 12000
 
diff --git a/source/blender/editors/space_view3d/view3d_navigate.c b/source/blender/editors/space_view3d/view3d_navigate.c
index d1e7f6ffb12..349371f8e5a 100644
--- a/source/blender/editors/space_view3d/view3d_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_navigate.c
@@ -41,6 +41,25 @@
 
 #include "view3d_navigate.h" /* own include */
 
+/* The names here indicate which navigation operators are supported in #ED_view3d_navigation_do */
+const char *op_idnames[] = {
+    [V3D_ZOOM] = "VIEW3D_OT_zoom",
+    [V3D_ROTATE] = "VIEW3D_OT_rotate",
+    [V3D_MOVE] = "VIEW3D_OT_move",
+    [V3D_VIEW_PAN] = "VIEW3D_OT_view_pan",
+// "VIEW3D_OT_dolly",
+// "VIEW3D_OT_view_center_pick",
+// "VIEW3D_OT_view_orbit",
+// "VIEW3D_OT_zoom_border",
+// "VIEW3D_OT_view_roll",
+#ifdef WITH_INPUT_NDOF
+// "VIEW3D_OT_ndof_orbit_zoom",
+// "VIEW3D_OT_ndof_pan",
+// "VIEW3D_OT_ndof_orbit",
+// "VIEW3D_OT_ndof_all",
+#endif
+};
+
 /* -------------------------------------------------------------------- */
 /** \name Navigation Polls
  * \{ */
@@ -260,21 +279,27 @@ enum eViewOpsFlag viewops_flag_from_prefs(void)
                                 (U.uiflag & USER_DEPTH_NAVIGATE) != 0);
 }
 
-ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOpsFlag viewops_flag)
+static void viewops_data_init_context(bContext *C, ViewOpsData *r_vod)
 {
-  ViewOpsData *vod = MEM_callocN(sizeof(ViewOpsData), __func__);
-
   /* Store data. */
-  vod->bmain = CTX_data_main(C);
-  vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
-  vod->scene = CTX_data_scene(C);
-  vod->area = CTX_wm_area(C);
-  vod->region = CTX_wm_region(C);
-  vod->v3d = vod->area->spacedata.first;
-  vod->rv3d = vod->region->regiondata;
+  r_vod->bmain = CTX_data_main(C);
+  r_vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+  r_vod->scene = CTX_data_scene(C);
+  r_vod->area = CTX_wm_area(C);
+  r_vod->region = CTX_wm_region(C);
+  r_vod->v3d = r_vod->area->spacedata.first;
+  r_vod->rv3d = r_vod->region->regiondata;
+}
 
-  Depsgraph *depsgraph = vod->depsgraph;
-  RegionView3D *rv3d = vod->rv3d;
+static void viewops_data_init_navigation(bContext *C,
+                                         const wmEvent *event,
+                                         enum eViewOpsFlag viewops_flag,
+                                         ViewOpsData *r_vod)
+{
+  Depsgraph *depsgraph = r_vod->depsgraph;
+  RegionView3D *rv3d = r_vod->rv3d;
+  View3D *v3d = r_vod->v3d;
+  ARegion *region = r_vod->region;
 
   /* Could do this more nicely. */
   if ((viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) == 0) {
@@ -284,62 +309,59 @@ ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOp
   /* we need the depth info before changing any viewport options */
   if (viewops_flag & VIEWOPS_FLAG_DEPTH_NAVIGATE) {
     float fallback_depth_pt[3];
-
-    view3d_operator_needs_opengl(C); /* Needed for Z-buffer drawing. */
-
     negate_v3_v3(fallback_depth_pt, rv3d->ofs);
 
-    vod->use_dyn_ofs = ED_view3d_autodist(
-        depsgraph, vod->region, vod->v3d, event->mval, vod->dyn_ofs, true, fallback_depth_pt);
+    r_vod->use_dyn_ofs = ED_view3d_autodist(
+        depsgraph, region, v3d, event->mval, r_vod->dyn_ofs, true, fallback_depth_pt);
   }
   else {
-    vod->use_dyn_ofs = false;
+    r_vod->use_dyn_ofs = false;
   }
 
   if (viewops_flag & VIEWOPS_FLAG_PERSP_ENSURE) {
-    if (ED_view3d_persp_ensure(depsgraph, vod->v3d, vod->region)) {
+    if (ED_view3d_persp_ensure(depsgraph, v3d, region)) {
       /* If we're switching from camera view to the perspective one,
        * need to tag viewport update, so camera view and borders are properly updated. */
-      ED_region_tag_redraw(vod->region);
+      ED_region_tag_redraw(region);
     }
   }
 
   /* set the view from the camera, if view locking is enabled.
    * we may want to make this optional but for now its needed always */
-  ED_view3d_camera_lock_init(depsgraph, vod->v3d, vod->rv3d);
+  ED_view3d_camera_lock_init(depsgraph, v3d, rv3d);
 
-  vod->init.persp = rv3d->persp;
-  vod->init.dist = rv3d->dist;
-  vod->init.camzoom = rv3d->camzoom;
-  copy_qt_qt(vod->init.quat, rv3d->viewquat);
-  copy_v2_v2_int(vod->init.event_xy, event->xy);
-  copy_v2_v2_int(vod->prev.event_xy, event->xy);
+  r_vod->init.persp = rv3d->persp;
+  r_vod->init.dist = rv3d->dist;
+  r_vod->init.camzoom = rv3d->camzoom;
+  copy_qt_qt(r_vod->init.quat, rv3d->viewquat);
+  copy_v2_v2_int(r_vod->init.event_xy, event->xy);
+  copy_v2_v2_int(r_vod->prev.event_xy, event->xy);
 
   if (viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) {
-    zero_v2_int(vod->init.event_xy_offset);
+    zero_v2_int(r_vod->init.event_xy_offset);
   }
   else {
     /* Simulate the event starting in the middle of the region. */
-    vod->init.event_xy_offset[0] = BLI_rcti_cent_x(&vod->region->winrct) - event->xy[0];
-    vod->init.event_xy_offset[1] = BLI_rcti_cent_y(&vod->region->winrct) - event->xy[1];
+    r_vod->init.event_xy_offset[0] = BLI_rcti_cent_x(&region->winrct) - event->xy[0];
+    r_vod->init.event_xy_offset[1] = BLI_rcti_cent_y(&region->winrct) - event->xy[1];
   }
 
-  vod->init.event_type = event->type;
-  copy_v3_v3(vod->init.ofs, rv3d->ofs);
+  r_vod->init.event_type = event->type;
+  copy_v3_v3(r_vod->init.ofs, rv3d->ofs);
 
-  copy_qt_qt(vod->curr.viewquat, rv3d->viewquat);
+  copy_qt_qt(r_vod->curr.viewquat, rv3d->viewquat);
 
   if (viewops_flag & VIEWOPS_FLAG_ORBIT_SELECT) {
     float ofs[3];
-    if (view3d_orbit_calc_center(C, ofs) || (vod->use_dyn_ofs == false)) {
-      vod->use_dyn_ofs = true;
-      negate_v3_v3(vod->dyn_ofs, ofs);
+    if (view3d_orbit_calc_center(C, ofs) || (r_vod->use_dyn_ofs == false)) {
+      r_vod->use_dyn_ofs = true;
+      negate_v3_v3(r_vod->dyn_ofs, ofs);
       viewops_flag &= ~VIEWOPS_FLAG_DEPTH_NAVIGATE;
     }
   }
 
   if (viewops_flag & VIEWOPS_FLAG_DEPTH_NAVIGATE) {
-    if (vod->use_dyn_ofs) {
+    if (r_vod->use_dyn_ofs) {
       if (rv3d->is_persp) {
         float my_origin[3]; /* Original #RegionView3D.ofs. */
         float my_pivot[3];  /* View pivot. */
@@ -365,51 +387,56 @@ ViewOpsData *viewops_data_create(bContext *C, const wmEvent *event, enum eViewOp
 
         /* find a new ofs value that is along the view axis
          * (rather than the mouse location) */
-        closest_to_line_v3(dvec, vod->dyn_ofs, my_pivot, my_origin);
-        vod->init.dist = rv3d->dist = len_v3v3(my_pivot, dvec);
+        closest_to_line_v3(dvec, r_vod->dyn_ofs, my_pivot, my_origin);
+        r_vod->init.dist = rv3d->dist = len_v3v3(my_pivot, dvec);
 
         negate_v3_v3(rv3d->ofs, dvec);
       }
       else {
-        const float mval_region_mid[2] = {(float)vod->region->winx / 2.0f,
-                                          (float)vod->region->winy / 2.0f};
+        const float mval_region_mid[2] = {(float)region->winx / 2.0f, (float)region->winy / 2.0f};
 
-        ED_view3d_win_to_3d(vod->v3d, vod->region, vod->dyn_ofs, mval_region_mid, rv3d->ofs);
+        ED_view3d_win_to_3d(v3d, region, r_vod->dyn_ofs, mval_region_mid, rv3d->ofs);
         negate_v3(rv3d->ofs);
       }
-      negate_v3(vod->dyn_ofs);
-      copy_v3_v3(vod->init.ofs, rv3d->ofs);
+      negate_v3(r_vod->dyn_ofs);
+      copy_v3_v3(r_vod->init.ofs, rv3d->ofs);
     }
   }
 
   /* For dolly */
-  ED_view3d_win_to_vector(vod->region, (const float[2]){UNPACK2(event->mval)}, vod->init.mousevec);
+  ED_view3d_win_to_vector(region, (const float[2]){UNPACK2(event->mval)}, r_vod->init.mousevec);
 
   {
     int event_xy_offset[2];
-    add_v2_v2v2_int(event_xy_offset, event->xy, vod->init.event_xy_offs

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list