Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_view3d / view3d_draw.c
index cf43d65b44a01c64e9a367bb48cc27945d53f6b3..f734bb085d035dabbcae3f89e4e5347139198067 100644 (file)
@@ -133,11 +133,18 @@ void ED_view3d_update_viewmat(
                view3d_winmatrix_set(depsgraph, ar, v3d, rect);
 
        /* setup view matrix */
-       if (viewmat)
+       if (viewmat) {
                copy_m4_m4(rv3d->viewmat, viewmat);
-       else
-               view3d_viewmatrix_set(eval_ctx, scene, v3d, rv3d);  /* note: calls BKE_object_where_is_calc for camera... */
-
+       }
+       else {
+               float rect_scale[2];
+               if (rect) {
+                       rect_scale[0] = (float)BLI_rcti_size_x(rect) / (float)ar->winx;
+                       rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)ar->winy;
+               }
+               /* note: calls BKE_object_where_is_calc for camera... */
+               view3d_viewmatrix_set(eval_ctx, scene, v3d, rv3d, rect ? rect_scale : NULL);
+       }
        /* update utility matrices */
        mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
        invert_m4_m4(rv3d->persinv, rv3d->persmat);