Commit: 0b5d0f981860c985bf4f58f9c8c5a13e948c967f
Author: Campbell Barton
Date:   Tue Feb 4 21:31:52 2014 +1100
https://developer.blender.org/rB0b5d0f981860c985bf4f58f9c8c5a13e948c967f

View3d: move lock check for orbit into a function and use for dolly too

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

M       source/blender/editors/include/ED_view3d.h
M       source/blender/editors/space_view3d/view3d_edit.c

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

diff --git a/source/blender/editors/include/ED_view3d.h 
b/source/blender/editors/include/ED_view3d.h
index a76c904..c10afd6 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -313,6 +313,8 @@ bool ED_view3d_lock(struct RegionView3D *rv3d);
 uint64_t ED_view3d_datamask(struct Scene *scene, struct View3D *v3d);
 uint64_t ED_view3d_screen_datamask(struct bScreen *screen);
 
+bool ED_view3d_view_lock_check(struct View3D *v3d, struct RegionView3D *rv3d);
+
 bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D 
*rv3d);
 
 /* camera lock functions */
diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index 190ac4c..3754b18 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -85,6 +85,26 @@
 /* for ndof prints */
 // #define DEBUG_NDOF_MOTION
 
+/**
+ * Mostly this function just checks ``rv3d->viewlock & RV3D_LOCKED`` however 
there is a
+ * special case where the flag is set but the user already switched out of an 
axis locked view.
+ *
+ * The 'view' in the function name refers to #RegionView3D.view which we may 
be locked.
+ *
+ * Functions which change the 'view' should call this check first, or...
+ * only apply to the user view (in the instance of a quad-view setup).
+ */
+bool ED_view3d_view_lock_check(View3D *UNUSED(v3d), RegionView3D *rv3d)
+{
+       if (rv3d->viewlock & RV3D_LOCKED) {
+               if ((RV3D_VIEW_IS_AXIS(rv3d->view) || rv3d->view == 
RV3D_VIEW_CAMERA)) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 bool ED_view3d_offset_lock_check(struct View3D *v3d, struct RegionView3D *rv3d)
 {
        return (rv3d->persp != RV3D_CAMOB) && (v3d->ob_centre_cursor || 
v3d->ob_centre);
@@ -986,7 +1006,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_LOCKED) && 
RV3D_VIEW_IS_AXIS(vod->rv3d->view)) {
+       if (ED_view3d_view_lock_check(vod->v3d, vod->rv3d)) {
                viewops_data_free(C, op);
                return OPERATOR_PASS_THROUGH;
        }
@@ -2262,7 +2282,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_LOCKED) && 
RV3D_VIEW_IS_AXIS(vod->rv3d->view)) {
+       if (ED_view3d_view_lock_check(vod->v3d, vod->rv3d)) {
                viewops_data_free(C, op);
                return OPERATOR_PASS_THROUGH;
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to