[Bf-blender-cvs] [e07f2aec7e7] vr_scene_inspection: Refactor RegionView3D runtime lock flag handling

Julian Eisel noreply at git.blender.org
Wed Mar 11 22:18:42 CET 2020


Commit: e07f2aec7e7296c08cc4d949c476130886c8e43d
Author: Julian Eisel
Date:   Wed Mar 11 22:17:19 2020 +0100
Branches: vr_scene_inspection
https://developer.blender.org/rBe07f2aec7e7296c08cc4d949c476130886c8e43d

Refactor RegionView3D runtime lock flag handling

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

M	source/blender/blenloader/intern/readfile.c
M	source/blender/draw/intern/draw_manager.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_fly.c
M	source/blender/editors/space_view3d/view3d_gizmo_navigate.c
M	source/blender/editors/space_view3d/view3d_utils.c
M	source/blender/editors/space_view3d/view3d_view.c
M	source/blender/editors/space_view3d/view3d_walk.c
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8a68be141f7..f1ac4db421b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7103,10 +7103,7 @@ static void direct_link_region(FileData *fd, ARegion *region, int spacetype)
         rv3d->smooth_timer = NULL;
 
         rv3d->rflag &= ~(RV3D_NAVIGATING | RV3D_PAINTING);
-        /* Clear runtime-only locks. */
-        if (rv3d->viewlock & RV3D_LOCK_RUNTIME_ONLY) {
-          rv3d->viewlock &= ~(RV3D_LOCK_ANY_TRANSFORM | RV3D_LOCK_RUNTIME_ONLY);
-        }
+        rv3d->runtime_viewlock = 0;
       }
     }
   }
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index b9711b4f88f..bd644ecc459 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -562,7 +562,7 @@ static void drw_viewport_var_init(void)
     DRW_view_camtexco_set(DST.view_default, rv3d->viewcamtexcofac);
 
     if (DST.draw_ctx.sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-      int plane_len = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6;
+      int plane_len = (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXCLIP) ? 4 : 6;
       DRW_view_clip_planes_set(DST.view_default, rv3d->clip, plane_len);
     }
 
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 5d27a09687b..a72b18f63f8 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -3818,6 +3818,7 @@ static void region_quadview_init_rv3d(
   }
 
   rv3d->viewlock = viewlock;
+  rv3d->runtime_viewlock = 0;
   rv3d->view = view;
   rv3d->view_axis_roll = RV3D_VIEW_AXIS_ROLL_0;
   rv3d->persp = persp;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index d0df54f046c..f659c0d1e4d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -341,7 +341,7 @@ static void view3d_xr_mirror_setup(const wmWindowManager *wm,
   copy_m4_m4(viewmat, rv3d->viewmat);
 
   WM_xr_session_state_viewer_matrix_info_get(&wm->xr, viewmat, &v3d->lens);
-  rv3d->viewlock |= (RV3D_LOCK_ANY_TRANSFORM | RV3D_LOCK_RUNTIME_ONLY);
+  rv3d->runtime_viewlock |= RV3D_LOCK_ANY_TRANSFORM;
   /* Just change to perspective mode, not worth resetting this. */
   rv3d->persp = RV3D_PERSP;
 
@@ -1527,7 +1527,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *region)
   wmWindowManager *wm = CTX_wm_manager(C);
 
 #ifdef WITH_INPUT_NDOF
-  if ((U.ndof_flag & NDOF_SHOW_GUIDE) && ((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) &&
+  if ((U.ndof_flag & NDOF_SHOW_GUIDE) && ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0) &&
       (rv3d->persp != RV3D_CAMOB)) {
     /* TODO: draw something else (but not this) during fly mode */
     draw_rotation_guide(rv3d);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index e59836271b4..0c4f59c1940 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -93,7 +93,7 @@ static bool view3d_camera_user_poll(bContext *C)
 
   if (ED_view3d_context_user_region(C, &v3d, &region)) {
     RegionView3D *rv3d = region->regiondata;
-    if ((rv3d->persp == RV3D_CAMOB) && !(rv3d->viewlock & RV3D_LOCK_ANY_TRANSFORM)) {
+    if ((rv3d->persp == RV3D_CAMOB) && !(RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM)) {
       return 1;
     }
   }
@@ -117,7 +117,7 @@ static bool view3d_pan_poll(bContext *C)
 {
   if (ED_operator_region_view3d_active(C)) {
     const RegionView3D *rv3d = CTX_wm_region_view3d(C);
-    return !(rv3d->viewlock & RV3D_LOCK_LOCATION);
+    return !(RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_LOCATION);
   }
   return false;
 }
@@ -126,7 +126,7 @@ static bool view3d_zoom_or_dolly_poll(bContext *C)
 {
   if (ED_operator_region_view3d_active(C)) {
     const RegionView3D *rv3d = CTX_wm_region_view3d(C);
-    return !(rv3d->viewlock & RV3D_LOCK_ZOOM_AND_DOLLY);
+    return !(RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ZOOM_AND_DOLLY);
   }
   return false;
 }
@@ -981,7 +981,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   vod = op->customdata;
 
   /* poll should check but in some cases fails, see poll func for details */
-  if (vod->rv3d->viewlock & RV3D_LOCK_ROTATION) {
+  if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_LOCK_ROTATION) {
     viewops_data_free(C, op);
     return OPERATOR_PASS_THROUGH;
   }
@@ -1069,7 +1069,7 @@ static bool ndof_has_translate(const wmNDOFMotionData *ndof,
 
 static bool ndof_has_rotate(const wmNDOFMotionData *ndof, const RegionView3D *rv3d)
 {
-  return !is_zero_v3(ndof->rvec) && ((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0);
+  return !is_zero_v3(ndof->rvec) && ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0);
 }
 
 /**
@@ -1177,7 +1177,7 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof,
     /* move center of view opposite of hand motion (this is camera mode, not object mode) */
     sub_v3_v3(rv3d->ofs, pan_vec);
 
-    if (rv3d->viewlock & RV3D_BOXVIEW) {
+    if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
       view3d_boxview_sync(sa, region);
     }
   }
@@ -1194,7 +1194,7 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof,
 
   float view_inv[4];
 
-  BLI_assert((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0);
+  BLI_assert((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0);
 
   ED_view3d_persp_ensure(vod->depsgraph, v3d, region);
 
@@ -1418,7 +1418,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
     const bool has_rotation = ndof_has_rotate(ndof, rv3d);
     /* if we can't rotate, fallback to translate (locked axis views) */
     const bool has_translate = ndof_has_translate(ndof, v3d, rv3d) &&
-                               (rv3d->viewlock & RV3D_LOCK_ROTATION);
+                               (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION);
     const bool has_zoom = (ndof->tvec[2] != 0.0f) && !rv3d->is_persp;
 
     if (has_translate || has_zoom) {
@@ -1750,7 +1750,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y)
 
     add_v3_v3(vod->rv3d->ofs, dvec);
 
-    if (vod->rv3d->viewlock & RV3D_BOXVIEW) {
+    if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
       view3d_boxview_sync(vod->sa, vod->region);
     }
   }
@@ -1826,7 +1826,7 @@ static int viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   /* makes op->customdata */
   viewops_data_alloc(C, op);
   vod = op->customdata;
-  if (vod->rv3d->viewlock & RV3D_LOCK_LOCATION) {
+  if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_LOCK_LOCATION) {
     viewops_data_free(C, op);
     return OPERATOR_PASS_THROUGH;
   }
@@ -2188,7 +2188,7 @@ static void viewzoom_apply_3d(ViewOpsData *vod,
   /* these limits were in old code too */
   CLAMP(vod->rv3d->dist, dist_range[0], dist_range[1]);
 
-  if (vod->rv3d->viewlock & RV3D_BOXVIEW) {
+  if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
     view3d_boxview_sync(vod->sa, vod->region);
   }
 
@@ -2341,7 +2341,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
     }
   }
 
-  if (rv3d->viewlock & RV3D_BOXVIEW) {
+  if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
     view3d_boxview_sync(sa, region);
   }
 
@@ -2537,7 +2537,7 @@ static void viewdolly_apply(ViewOpsData *vod, const int xy[2], const short zoom_
     view_dolly_to_vector_3d(vod->region, vod->init.ofs, vod->init.mousevec, zfac);
   }
 
-  if (vod->rv3d->viewlock & RV3D_BOXVIEW) {
+  if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) {
     view3d_boxview_sync(vod->sa, vod->region);
   }
 
@@ -2635,7 +2635,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
 
   view_dolly_to_vector_3d(region, rv3d->ofs, mousevec, delta < 0 ? 0.2f : 1.8f);
 
-  if (rv3d->viewlock & RV3D_BOXVIEW) {
+  if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
     view3d_boxview_sync(sa, region);
   }
 
@@ -2664,7 +2664,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
   vod = op->customdata;
 
   /* poll should check but in some cases fails, see poll func for details */
-  if (vod->rv3d->viewlock & RV3D_LOCK_ROTATION) {
+  if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_LOCK_ROTATION) {
     viewops_data_free(C, op);
     return OPERATOR_PASS_THROUGH;
   }
@@ -3724,7 +3724,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
                             .dist = &new_dist,
                         });
 
-  if (rv3d->viewlock & RV3D_BOXVIEW) {
+  if (RV3D_LOCK_FLAGS(rv3d) & RV3D_BOXVIEW) {
     view3d_boxview_sync(CTX_wm_area(C), region);
   }
 
@@ -3857,7 +3857,7 @@ static void axis_set_view(bContext *C,
     rv3d->view_axis_roll = view_axis_roll;
   }
 
-  if (rv3d->viewlock & RV3D_LOCK_ROTATION) {
+  if (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) {
     ED_region_tag_redraw(region);
     return;
   }
@@ -4081,7 +4081,7 @@ static int view_camera_exec(bContext *C, wmOperator *op)
 
   ED_view3d_smooth_view_force_finish(C, v3d, region);
 
-  if ((rv3d->viewlock & RV3D_LOCK_ANY_TRANSFORM) == 0) {
+  if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) {
     /* lastview -  */
 
     ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -4230,7 +4230,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
                                                   RV3D_VIEW_USER;
   orbitdir = RNA_enum_get(op->ptr, "type");
 
-  if ((rv3d->viewlock & RV3D_LOCK_ROTATION) && (view_opposite == RV3D_VIEW_USER)) {
+  if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) && (view_opposite == RV3D_VIEW_USER)) {
     /* no NULL check is needed, poll checks */
     ED_view3d_context_user_region(C, &v3d, &region);
     rv3d = region->regiondata;
@@ -4238,7 +4238,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
 
   ED_view3d_smooth_view_force_finish(C, v3d, region);
 
-  if ((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0 || (view_opposite != RV3D_VIEW_USER)) {
+  if ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0 || (view_opposite != RV3D_VIEW_USER)) {
     if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list