bugfix [#24122] Shift-C doesn't work in "Camera View"
[blender.git] / source / blender / editors / space_view3d / view3d_view.c
index d66144b2c30afe83a2b9659d6bb80f349535c20d..860f9f461c43370d46e0e39837eb702de59e3a09 100644 (file)
@@ -205,7 +205,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
        if(quat) copy_qt_qt(sms.new_quat, quat);
        if(dist) sms.new_dist= *dist;
        if(lens) sms.new_lens= *lens;
-       
+
        if (camera) {
                view3d_settings_from_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens);
                sms.to_camera= 1; /* restore view3d values in end */
@@ -214,15 +214,15 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
        if (C && U.smooth_viewtx) {
                int changed = 0; /* zero means no difference */
                
-               if (sms.new_dist != rv3d->dist)
+               if (oldcamera != camera)
                        changed = 1;
-               if (sms.new_lens != v3d->lens)
+               else if (sms.new_dist != rv3d->dist)
                        changed = 1;
-               
-               if (!equals_v3v3(sms.new_ofs, rv3d->ofs))
+               else if (sms.new_lens != v3d->lens)
                        changed = 1;
-
-               if (!equals_v4v4(sms.new_quat, rv3d->viewquat))
+               else if (!equals_v3v3(sms.new_ofs, rv3d->ofs))
+                       changed = 1;
+               else if (!equals_v4v4(sms.new_quat, rv3d->viewquat))
                        changed = 1;
                
                /* The new view is different from the old one
@@ -449,17 +449,21 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
        View3D *v3d = CTX_wm_view3d(C);
        RegionView3D *rv3d= CTX_wm_region_view3d(C);
        Scene *scene= CTX_data_scene(C);
-       
-       if(BASACT) {
+       Object *ob = CTX_data_active_object(C);
+
+       if(ob) {
+               Object *camera_old= (rv3d->persp == RV3D_CAMOB && scene->camera) ? scene->camera : NULL;
                rv3d->persp= RV3D_CAMOB;
-               v3d->camera= OBACT;
+               v3d->camera= ob;
                if(v3d->scenelock)
-                       scene->camera= OBACT;
-               smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
+                       scene->camera= ob;
+
+               if(camera_old != ob) /* unlikely but looks like a glitch when set to the same */
+                       smooth_view(C, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
+
+               WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C));
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C));
-       
        return OPERATOR_FINISHED;
 }