Fix 3D smooth-view ignoring lens when exiting camera view

Add NULL checks for `sview->ofs`, while it's currently never NULL
when a camera is set. The API allows for each member
to be set independently.
This commit is contained in:
Erik Abrahamsson 2020-10-29 12:33:26 +11:00 committed by Campbell Barton
parent 52b38d9c3d
commit 01d02e78b5
3 changed files with 15 additions and 5 deletions

View File

@ -3910,6 +3910,7 @@ static void axis_set_view(bContext *C,
region,
smooth_viewtx,
&(const V3D_SmoothParams){
.camera_old = camera_eval,
.ofs = ofs,
.quat = quat,
.dist = &dist,

View File

@ -170,10 +170,16 @@ bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d,
float obmat[4][4]);
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
/**
* Parameters for setting the new view-port state.
*
* Each of the struct members may be NULL to signify they aren't to be adjusted.
*/
typedef struct V3D_SmoothParams {
struct Object *camera_old, *camera;
const float *ofs, *quat, *dist, *lens;
/* alternate rotation center (ofs = must be NULL) */
/** Alternate rotation center, when set `ofs` must be NULL. */
const float *dyn_ofs;
} V3D_SmoothParams;

View File

@ -192,8 +192,10 @@ void ED_view3d_smooth_view_ex(
if (sview->camera) {
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
sms.dst.dist = ED_view3d_offset_distance(
ob_camera_eval->obmat, sview->ofs, VIEW3D_DIST_FALLBACK);
if (sview->ofs != NULL) {
sms.dst.dist = ED_view3d_offset_distance(
ob_camera_eval->obmat, sview->ofs, VIEW3D_DIST_FALLBACK);
}
ED_view3d_from_object(ob_camera_eval, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens);
sms.to_camera = true; /* restore view3d values in end */
}
@ -224,8 +226,9 @@ void ED_view3d_smooth_view_ex(
/* original values */
if (sview->camera_old) {
Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, sview->camera_old);
sms.src.dist = ED_view3d_offset_distance(ob_camera_old_eval->obmat, rv3d->ofs, 0.0f);
/* this */
if (sview->ofs != NULL) {
sms.src.dist = ED_view3d_offset_distance(ob_camera_old_eval->obmat, sview->ofs, 0.0f);
}
ED_view3d_from_object(
ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
}