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
This commit is contained in:
parent
66800a1deb
commit
77a6b6fb1a
Notes:
blender-bot
2023-02-14 06:17:14 +01:00
Referenced by issue #80819, Zoom To Border operator - zoom factor is too high in the perspective view.
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue