make previous commit work when the camera is locked to the view (in that case use the camera lens, not the viewport lens value).
This commit is contained in:
@@ -219,7 +219,7 @@ void ED_view3d_clipping_enable(void);
|
||||
void ED_view3d_clipping_disable(void);
|
||||
|
||||
float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]);
|
||||
float ED_view3d_dist_from_radius(struct View3D *v3d, const float radius);
|
||||
float ED_view3d_dist_from_radius(const float angle, const float radius);
|
||||
|
||||
void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user