Fix for view lock checks with ndof ops, was incorrectly comparing flags
authorCampbell Barton <ideasman42@gmail.com>
Tue, 4 Feb 2014 10:04:36 +0000 (21:04 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 4 Feb 2014 10:45:13 +0000 (21:45 +1100)
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/space_view3d/view3d_walk.c

index 9125d439432d28ef9131cb69d3c8534c07f7b397..3a9c267f1cdc399f1e87dd350fca29a259753b5e 100644 (file)
@@ -178,7 +178,7 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar)
 
                if (ar) {
                        RegionView3D *rv3d = ar->regiondata;
-                       if (rv3d && rv3d->viewlock == 0) {
+                       if (rv3d && (rv3d->viewlock & RV3D_LOCKED) == 0) {
                                *r_v3d = v3d;
                                *r_ar = ar;
                                return true;
@@ -190,7 +190,7 @@ bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar)
                                        /* find the first unlocked rv3d */
                                        if (ar->regiondata && ar->regiontype == RGN_TYPE_WINDOW) {
                                                rv3d = ar->regiondata;
-                                               if (rv3d->viewlock == 0) {
+                                               if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
                                                        ar_unlock = ar;
                                                        if (rv3d->persp == RV3D_PERSP || rv3d->persp == RV3D_CAMOB) {
                                                                ar_unlock_user = ar;
index ad5f393f9565d0463867cd22403ab4879e615a1d..08ef69101904f87de246b4d3371b64045470ef27 100644 (file)
@@ -3375,7 +3375,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
                BDR_drawSketch(C);
        }
 
-       if ((U.ndof_flag & NDOF_SHOW_GUIDE) && (rv3d->viewlock != RV3D_LOCKED) && (rv3d->persp != RV3D_CAMOB))
+       if ((U.ndof_flag & NDOF_SHOW_GUIDE) && ((rv3d->viewlock & RV3D_LOCKED) == 0) && (rv3d->persp != RV3D_CAMOB))
                /* TODO: draw something else (but not this) during fly mode */
                draw_rotation_guide(rv3d);
 
index cf9668608e78fdd42520c651c727424bd152f50c..190ac4cd7c0ede4530e34f7e7da07f9073858e87 100644 (file)
@@ -292,7 +292,7 @@ static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
                if (artest != ar && artest->regiontype == RGN_TYPE_WINDOW) {
                        RegionView3D *rv3dtest = artest->regiondata;
 
-                       if (rv3dtest->viewlock) {
+                       if (rv3dtest->viewlock & RV3D_LOCKED) {
                                rv3dtest->dist = rv3d->dist;
 
                                if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
@@ -331,7 +331,7 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
 {
        ARegion *artest;
        RegionView3D *rv3d = ar->regiondata;
-       short clip = 0;
+       bool clip = false;
 
        for (artest = sa->regionbase.first; artest; artest = artest->next) {
                if (artest != ar && artest->regiontype == RGN_TYPE_WINDOW) {
@@ -342,7 +342,7 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
                                copy_v3_v3(rv3dtest->ofs, rv3d->ofs);
                                ED_region_tag_redraw(artest);
 
-                               clip |= rv3dtest->viewlock & RV3D_BOXCLIP;
+                               clip |= ((rv3dtest->viewlock & RV3D_BOXCLIP) != 0);
                        }
                }
        }
@@ -986,7 +986,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_VIEW_IS_AXIS(vod->rv3d->view)) {
+       if ((vod->rv3d->viewlock & RV3D_LOCKED) && RV3D_VIEW_IS_AXIS(vod->rv3d->view)) {
                viewops_data_free(C, op);
                return OPERATOR_PASS_THROUGH;
        }
@@ -1212,7 +1212,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                        const float zoom_sensitivity = 1.f;
 #endif
                        const float pan_sensitivity = 1.f;
-                       const bool has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec);
+                       const bool has_rotation = ((rv3d->viewlock & RV3D_LOCKED) == 0) && !is_zero_v3(ndof->rvec);
 
                        float view_inv[4];
                        invert_qt_qt(view_inv, rv3d->viewquat);
@@ -1222,7 +1222,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                               ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt);
 #endif
 
-                       if (rv3d->viewlock == RV3D_LOCKED) {
+                       if (rv3d->viewlock & RV3D_LOCKED) {
                                /* rotation not allowed -- explore panning options instead */
                                float pan_vec[3] = {ndof->tx, ndof->ty, 0.0f};
                                mul_v3_fl(pan_vec, pan_sensitivity * rv3d->dist * dt);
@@ -1296,7 +1296,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
                        const float zoom_sensitivity = 1.f;
 
                        const float pan_sensitivity = 1.f;
-                       const bool has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec);
+                       const bool has_rotation = ((rv3d->viewlock & RV3D_LOCKED) == 0) && !is_zero_v3(ndof->rvec);
 
                        float view_inv[4];
                        invert_qt_qt(view_inv, rv3d->viewquat);
@@ -1320,7 +1320,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
                                rv3d->dist += zoom_distance;
                        }
                        
-                       if (rv3d->viewlock == RV3D_LOCKED) {
+                       if (rv3d->viewlock & RV3D_LOCKED) {
                                /* rotation not allowed -- explore panning options instead */
                                float pan_vec[3] = {ndof->tx, ndof->ty, 0.0f};
                                mul_v3_fl(pan_vec, pan_sensitivity * rv3d->dist * dt);
@@ -2261,7 +2261,8 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
        viewops_data_alloc(C, op);
        vod = op->customdata;
 
-       if (vod->rv3d->viewlock) { /* poll should check but in some cases fails, see poll func for details */
+       /* 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)) {
                viewops_data_free(C, op);
                return OPERATOR_PASS_THROUGH;
        }
@@ -3321,7 +3322,7 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar,
 
        if (align_active == false) {
                /* normal operation */
-               if (rv3d->viewlock) {
+               if (rv3d->viewlock & RV3D_LOCKED) {
                        /* only pass on if */
 
                        /* nice confusing if-block */
@@ -3339,7 +3340,7 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar,
                rv3d->view = view;
        }
 
-       if (rv3d->viewlock) {
+       if (rv3d->viewlock & RV3D_LOCKED) {
                ED_region_tag_redraw(ar);
                return;
        }
@@ -3383,7 +3384,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
        align_active = RNA_boolean_get(op->ptr, "align_active");
 
        /* set this to zero, gets handled in axis_set_view */
-       if (rv3d->viewlock)
+       if (rv3d->viewlock & RV3D_LOCKED)
                align_active = false;
 
        /* Use this to test if we started out with a camera */
@@ -3427,7 +3428,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
                        break;
 
                case RV3D_VIEW_CAMERA:
-                       if (rv3d->viewlock == 0) {
+                       if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
                                /* lastview -  */
 
                                if (rv3d->persp != RV3D_CAMOB) {
@@ -3548,7 +3549,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
 
        orbitdir = RNA_enum_get(op->ptr, "type");
 
-       if (rv3d->viewlock == 0) {
+       if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
                if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
                        const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
                        float angle = DEG2RADF((float)U.pad_rot_angle);
@@ -3864,7 +3865,7 @@ static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op))
        ED_view3d_context_user_region(C, &v3d_dummy, &ar);
        rv3d = ar->regiondata;
 
-       if (rv3d->viewlock == 0) {
+       if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
                if (rv3d->persp != RV3D_ORTHO)
                        rv3d->persp = RV3D_ORTHO;
                else rv3d->persp = RV3D_PERSP;
index 5f8962a4e909d5626f86ff2c4ab373fb4e3f4dbd..bfb7b36318ac26dc5c42e5655fa55d5ddbed16eb 100644 (file)
@@ -1043,7 +1043,7 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
        RegionView3D *rv3d = CTX_wm_region_view3d(C);
        FlyInfo *fly;
 
-       if (rv3d->viewlock)
+       if (rv3d->viewlock & RV3D_LOCKED)
                return OPERATOR_CANCELLED;
 
        fly = MEM_callocN(sizeof(FlyInfo), "FlyOperation");
index faf83cdd772a2f16e3b41053cacfbcb77a571c74..150ac3612918d2e67c8023169351e4c2200ebbbc 100644 (file)
@@ -434,7 +434,7 @@ static int view3d_camera_to_view_poll(bContext *C)
        View3D *v3d = CTX_wm_view3d(C);
        if (v3d && v3d->camera && v3d->camera->id.lib == NULL) {
                RegionView3D *rv3d = CTX_wm_region_view3d(C);
-               if (rv3d && !rv3d->viewlock) {
+               if (rv3d && (rv3d->viewlock & RV3D_LOCKED) == 0) {
                        return 1;
                }
        }
@@ -854,7 +854,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d)
 
 
                /* should be moved to better initialize later on XXX */
-               if (rv3d->viewlock)
+               if (rv3d->viewlock & RV3D_LOCKED)
                        ED_view3d_lock(rv3d);
                
                quat_to_mat4(rv3d->viewmat, rv3d->viewquat);
index 31bb37e98f64aa551c9527adfcb42dfc3874fd53..218302be1685b9ebcab9c575fe65ac10639fec37 100644 (file)
@@ -1331,7 +1331,7 @@ static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event)
        RegionView3D *rv3d = CTX_wm_region_view3d(C);
        WalkInfo *walk;
 
-       if (rv3d->viewlock)
+       if (rv3d->viewlock & RV3D_LOCKED)
                return OPERATOR_CANCELLED;
 
        walk = MEM_callocN(sizeof(WalkInfo), "NavigationWalkOperation");