bugfix [#24122] Shift-C doesn't work in "Camera View"
[blender.git] / source / blender / editors / space_view3d / view3d_edit.c
index 06d93f01e02d782232cbe6266f7bb45c262b79bc..4cac0e297d17260e37da90a39ec57a140b97076f 100644 (file)
@@ -1274,7 +1274,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
        RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX);
 }
 
-static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
+static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
 {
        ARegion *ar= CTX_wm_region(C);
        View3D *v3d = CTX_wm_view3d(C);
@@ -1289,12 +1289,11 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
        int ok= 1, onedone=0;
 
        if(center) {
-               min[0]= min[1]= min[2]= 0.0f;
-               max[0]= max[1]= max[2]= 0.0f;
-
                /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
                curs= give_cursor(scene, v3d);
-               curs[0]= curs[1]= curs[2]= 0.0;
+               zero_v3(min);
+               zero_v3(max);
+               zero_v3(curs);
        }
        else {
                INIT_MINMAX(min, max);
@@ -1318,9 +1317,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
                return OPERATOR_FINISHED;
        }
 
-       afm[0]= (max[0]-min[0]);
-       afm[1]= (max[1]-min[1]);
-       afm[2]= (max[2]-min[2]);
+       sub_v3_v3v3(afm, max, min);
        size= 0.7f*MAX3(afm[0], afm[1], afm[2]);
        if(size==0.0) ok= 0;
 
@@ -1342,7 +1339,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
 
                if (rv3d->persp==RV3D_CAMOB) {
                        rv3d->persp= RV3D_PERSP;
-                       smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL);
+                       smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL);
                }
                else {
                        smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
@@ -1358,17 +1355,6 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
        return OPERATOR_FINISHED;
 }
 
-static int viewhome_poll(bContext *C)
-{
-       if(ED_operator_view3d_active(C)) {
-               RegionView3D *rv3d= CTX_wm_region_view3d(C); //XXX, when accessed from a header menu this doesnt work!
-               if(rv3d && rv3d->persp!=RV3D_CAMOB) {
-                       return 1;
-               }
-       }
-
-       return 0;
-}
 
 void VIEW3D_OT_view_all(wmOperatorType *ot)
 {
@@ -1378,8 +1364,8 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
        ot->idname= "VIEW3D_OT_view_all";
 
        /* api callbacks */
-       ot->exec= viewhome_exec;
-       ot->poll= viewhome_poll;
+       ot->exec= view3d_all_exec;
+       ot->poll= ED_operator_view3d_active;
 
        /* flags */
        ot->flag= 0;