Revision: 36839
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36839
Author:   campbellbarton
Date:     2011-05-23 15:46:09 +0000 (Mon, 23 May 2011)
Log Message:
-----------
fix [#27462] Linked Object (camera) can be moved by Lock Camera to View

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_view3d.h
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h    2011-05-23 
15:23:31 UTC (rev 36838)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h    2011-05-23 
15:46:09 UTC (rev 36839)
@@ -284,6 +284,7 @@
 unsigned int ED_viewedit_datamask(struct bScreen *screen);
 
 /* camera lock functions */
+int ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d);
 /* copy the camera to the view before starting a view transformation */
 void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d);
 /* copy the view to the camera */

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c     
2011-05-23 15:23:31 UTC (rev 36838)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c     
2011-05-23 15:46:09 UTC (rev 36839)
@@ -82,16 +82,24 @@
 
 /* ********************** view3d_edit: view manipulations 
********************* */
 
+int ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d)
+{
+       return ((v3d->camera) &&
+               (v3d->camera->id.lib == NULL) &&
+               (v3d->flag2 & V3D_LOCK_CAMERA) &&
+               (rv3d->persp==RV3D_CAMOB));
+}
+
 void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d)
 {
-       if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && 
(rv3d->persp==RV3D_CAMOB)) {
+       if(ED_view3d_camera_lock_check(v3d, rv3d)) {
                ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, 
&rv3d->dist, NULL);
        }
 }
 
 void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d)
 {
-       if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && 
(rv3d->persp==RV3D_CAMOB)) {
+       if(ED_view3d_camera_lock_check(v3d, rv3d)) {
                Object *root_parent;
 
                if((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (root_parent= 
v3d->camera->parent)) {
@@ -841,7 +849,7 @@
        if(rv3d->persp != RV3D_PERSP) {
 
                if (U.uiflag & USER_AUTOPERSP) {
-                       if(!((rv3d->persp==RV3D_CAMOB) && (vod->v3d->flag2 & 
V3D_LOCK_CAMERA))) {
+                       if(!ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) {
                                rv3d->persp= RV3D_PERSP;
                        }
                }
@@ -852,7 +860,7 @@
                                ED_view3d_from_object(vod->v3d->camera, 
rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL);
                        }
 
-                       if(!(vod->v3d->flag2 & V3D_LOCK_CAMERA)) {
+                       if(!ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) {
                                rv3d->persp= rv3d->lpersp;
                        }
                }
@@ -953,7 +961,7 @@
 
 static void viewmove_apply(ViewOpsData *vod, int x, int y)
 {
-       if((vod->rv3d->persp==RV3D_CAMOB) && !(vod->v3d->flag2 & 
V3D_LOCK_CAMERA)) {
+       if((vod->rv3d->persp==RV3D_CAMOB) && 
!ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) {
                const float zoomfac= 
BKE_screen_view3d_zoom_to_fac((float)vod->rv3d->camzoom) * 2.0f;
                vod->rv3d->camdx += (vod->oldx - x)/(vod->ar->winx * zoomfac);
                vod->rv3d->camdy += (vod->oldy - y)/(vod->ar->winy * zoomfac);
@@ -1284,7 +1292,7 @@
        mx= RNA_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : 
ar->winx / 2;
        my= RNA_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : 
ar->winy / 2;
 
-       use_cam_zoom= (rv3d->persp==RV3D_CAMOB) && !((v3d->flag2 & 
V3D_LOCK_CAMERA) && rv3d->is_persp);
+       use_cam_zoom= (rv3d->persp==RV3D_CAMOB) && !(rv3d->is_persp && 
ED_view3d_camera_lock_check(v3d, rv3d));
 
        if(delta < 0) {
                /* this min and max is also in viewmove() */
@@ -1625,7 +1633,7 @@
                }
                else {
                        View3D *v3d= CTX_wm_view3d(C);
-                       if ((rv3d->persp == RV3D_CAMOB) && (v3d->flag2 & 
V3D_LOCK_CAMERA)) {
+                       if (ED_view3d_camera_lock_check(v3d, rv3d)) {
                                return 1;
                        }
                }
@@ -1664,7 +1672,7 @@
        Scene *scene= CTX_data_scene(C);
        Base *base;
        float *curs;
-       const short skip_camera= ((rv3d->persp==RV3D_CAMOB) && (v3d->flag2 & 
V3D_LOCK_CAMERA));
+       const short skip_camera= ED_view3d_camera_lock_check(v3d, rv3d);
 
        int center= RNA_boolean_get(op->ptr, "center");
 
@@ -1725,7 +1733,7 @@
                        new_dist*= size;
                }
 
-               if ((rv3d->persp==RV3D_CAMOB) && !(v3d->flag2 & 
V3D_LOCK_CAMERA)) {
+               if ((rv3d->persp==RV3D_CAMOB) && 
!ED_view3d_camera_lock_check(v3d, rv3d)) {
                        rv3d->persp= RV3D_PERSP;
                        smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, 
NULL, &new_dist, NULL);
                }
@@ -1769,7 +1777,7 @@
        Object *obedit= CTX_data_edit_object(C);
        float size, min[3], max[3], afm[3];
        int ok=0, ok_dist=1;
-       const short skip_camera= ((rv3d->persp==RV3D_CAMOB) && (v3d->flag2 & 
V3D_LOCK_CAMERA));
+       const short skip_camera= ED_view3d_camera_lock_check(v3d, rv3d);
 
        /* SMOOTHVIEW */
        float new_ofs[3];
@@ -1872,7 +1880,7 @@
                new_dist*= size;
        }
 
-       if (rv3d->persp==RV3D_CAMOB && !(v3d->flag2 & V3D_LOCK_CAMERA)) {
+       if (rv3d->persp==RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) 
{
                rv3d->persp= RV3D_PERSP;
                smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, 
&new_dist, NULL);
        }
@@ -2176,7 +2184,7 @@
        RegionView3D *rv3d= CTX_wm_region_view3d(C);
 
        /* if in camera view do not exec the operator so we do not conflict 
with set render border*/
-       if ((rv3d->persp != RV3D_CAMOB) || (v3d->flag2 & V3D_LOCK_CAMERA))
+       if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, 
rv3d))
                return WM_border_select_invoke(C, op, event);
        else
                return OPERATOR_PASS_THROUGH;
@@ -2490,7 +2498,7 @@
        orbitdir = RNA_enum_get(op->ptr, "type");
 
        if(rv3d->viewlock==0) {
-               if((rv3d->persp != RV3D_CAMOB) || (v3d->flag2 & 
V3D_LOCK_CAMERA)) {
+               if((rv3d->persp != RV3D_CAMOB) || 
ED_view3d_camera_lock_check(v3d, rv3d)) {
                        if(orbitdir == V3D_VIEW_STEPLEFT || orbitdir == 
V3D_VIEW_STEPRIGHT) {
                                float si;
                                /* z-axis */

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to