Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Abrahamsson <erik85>2020-10-27 06:08:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-27 06:10:58 +0300
commit77a6b6fb1ac0a1973398790a245a013a9e1a684b (patch)
tree3e35356ec0ea1c2d595fd1b0aea8680f5a1f0ba1
parent66800a1deb2dc9e6cd13690a5246fbbea45c16b0 (diff)
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
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c14
1 files changed, 14 insertions, 0 deletions
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;
}