diff options
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 5 |
2 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index a37ce64b7c8..5daa404c572 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2224,8 +2224,22 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar, /* fix up zoom distance if needed */ if (rv3d->is_persp) { + float lens, sensor_size; /* offset the view based on the lens */ - size = ED_view3d_dist_from_radius(v3d, size / 2.0f); + if (rv3d->persp == RV3D_CAMOB && ED_view3d_camera_lock_check(v3d, rv3d)) { + CameraParams params; + BKE_camera_params_init(¶ms); + BKE_camera_params_from_object(¶ms, v3d->camera); + + lens = params.lens; + sensor_size = BKE_camera_sensor_size(params.sensor_fit, params.sensor_x, params.sensor_y); + } + else { + lens = v3d->lens; + sensor_size = DEFAULT_SENSOR_WIDTH; + } + size = ED_view3d_dist_from_radius(focallength_to_fov(lens, sensor_size), size / 2.0f); + if (size <= v3d->near * 1.5f) { /* do not zoom closer than the near clipping plane */ size = v3d->near * 1.5f; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index ea09aca900f..e79f24eea09 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1521,10 +1521,9 @@ float ED_view3d_pixel_size(RegionView3D *rv3d, const float co[3]) } /* use for perspective view only */ -float ED_view3d_dist_from_radius(View3D *v3d, const float radius) +float ED_view3d_dist_from_radius(const float angle, const float radius) { - const float angle = (((float)M_PI) - focallength_to_fov(v3d->lens, DEFAULT_SENSOR_WIDTH)); - return radius * fabsf(1.0f / cosf(angle / 2.0f)); + return radius * fabsf(1.0f / cosf((((float)M_PI) - angle) / 2.0f)); } /* view matrix properties utilities */ |