[Bf-blender-cvs] [77a6b6fb1ac] blender-v2.91-release: Fix T80819: Border zoom is isn't accurate in perspective view

Erik Abrahamsson noreply at git.blender.org
Tue Oct 27 04:13:08 CET 2020


Commit: 77a6b6fb1ac0a1973398790a245a013a9e1a684b
Author: Erik Abrahamsson
Date:   Tue Oct 27 14:08:12 2020 +1100
Branches: blender-v2.91-release
https://developer.blender.org/rB77a6b6fb1ac0a1973398790a245a013a9e1a684b

Fix T80819: Border zoom is isn't accurate in perspective view

Improved user experience by using viewport focal length
to calculate the new camera distance.

Also resizing the border to the same aspect ratio as
the window will help not zooming in more than expected.

Ref D9341

===================================================================

M	source/blender/editors/space_view3d/view3d_edit.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 233967fa89d..83a2254e811 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -3635,6 +3635,17 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
     MEM_SAFE_FREE(depth_temp.depths);
   }
 
+  /* Resize border to the same ratio as the window. */
+  {
+    const float region_aspect = (float)region->winx / (float)region->winy;
+    if (((float)BLI_rcti_size_x(&rect) / (float)BLI_rcti_size_y(&rect)) < region_aspect) {
+      BLI_rcti_resize_x(&rect, (int)(BLI_rcti_size_y(&rect) * region_aspect));
+    }
+    else {
+      BLI_rcti_resize_y(&rect, (int)(BLI_rcti_size_x(&rect) / region_aspect));
+    }
+  }
+
   cent[0] = (((float)rect.xmin) + ((float)rect.xmax)) / 2;
   cent[1] = (((float)rect.ymin) + ((float)rect.ymax)) / 2;
 
@@ -3657,6 +3668,9 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
 
     new_dist = len_v3(dvec);
 
+    /* Account for the lens, without this a narrow lens zooms in too close. */
+    new_dist *= (v3d->lens / DEFAULT_SENSOR_WIDTH);
+
     /* ignore dist_range min */
     dist_range[0] = v3d->clip_start * 1.5f;
   }



More information about the Bf-blender-cvs mailing list