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:
@@ -3910,6 +3910,7 @@ static void axis_set_view(bContext *C,
|
|||||||
region,
|
region,
|
||||||
smooth_viewtx,
|
smooth_viewtx,
|
||||||
&(const V3D_SmoothParams){
|
&(const V3D_SmoothParams){
|
||||||
|
.camera_old = camera_eval,
|
||||||
.ofs = ofs,
|
.ofs = ofs,
|
||||||
.quat = quat,
|
.quat = quat,
|
||||||
.dist = &dist,
|
.dist = &dist,
|
||||||
|
|||||||
@@ -170,10 +170,16 @@ bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d,
|
|||||||
float obmat[4][4]);
|
float obmat[4][4]);
|
||||||
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
|
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 {
|
typedef struct V3D_SmoothParams {
|
||||||
struct Object *camera_old, *camera;
|
struct Object *camera_old, *camera;
|
||||||
const float *ofs, *quat, *dist, *lens;
|
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;
|
const float *dyn_ofs;
|
||||||
} V3D_SmoothParams;
|
} V3D_SmoothParams;
|
||||||
|
|
||||||
|
|||||||
@@ -192,8 +192,10 @@ void ED_view3d_smooth_view_ex(
|
|||||||
|
|
||||||
if (sview->camera) {
|
if (sview->camera) {
|
||||||
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
|
Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, sview->camera);
|
||||||
|
if (sview->ofs != NULL) {
|
||||||
sms.dst.dist = ED_view3d_offset_distance(
|
sms.dst.dist = ED_view3d_offset_distance(
|
||||||
ob_camera_eval->obmat, sview->ofs, VIEW3D_DIST_FALLBACK);
|
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);
|
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 */
|
sms.to_camera = true; /* restore view3d values in end */
|
||||||
}
|
}
|
||||||
@@ -224,8 +226,9 @@ void ED_view3d_smooth_view_ex(
|
|||||||
/* original values */
|
/* original values */
|
||||||
if (sview->camera_old) {
|
if (sview->camera_old) {
|
||||||
Object *ob_camera_old_eval = DEG_get_evaluated_object(depsgraph, 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);
|
if (sview->ofs != NULL) {
|
||||||
/* this */
|
sms.src.dist = ED_view3d_offset_distance(ob_camera_old_eval->obmat, sview->ofs, 0.0f);
|
||||||
|
}
|
||||||
ED_view3d_from_object(
|
ED_view3d_from_object(
|
||||||
ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
|
ob_camera_old_eval, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user