From ca1f879c0254ba40188a7cdd40f564b12a82cd43 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 18 Feb 2022 17:16:05 +1100 Subject: Cleanup: simplify viewmove_apply Check for a camera-view before checking if the view is locked to the cursor/object since the camera-view takes priority, it reads better to check that first. Also reuse the event offset variable. --- .../blender/editors/space_view3d/view3d_navigate.c | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_view3d/view3d_navigate.c b/source/blender/editors/space_view3d/view3d_navigate.c index d1e7b5891e9..21e0459f346 100644 --- a/source/blender/editors/space_view3d/view3d_navigate.c +++ b/source/blender/editors/space_view3d/view3d_navigate.c @@ -544,26 +544,24 @@ static void axis_set_view(bContext *C, void viewmove_apply(ViewOpsData *vod, int x, int y) { - if (ED_view3d_offset_lock_check(vod->v3d, vod->rv3d)) { - vod->rv3d->ofs_lock[0] -= ((vod->prev.event_xy[0] - x) * 2.0f) / (float)vod->region->winx; - vod->rv3d->ofs_lock[1] -= ((vod->prev.event_xy[1] - y) * 2.0f) / (float)vod->region->winy; - } - else if ((vod->rv3d->persp == RV3D_CAMOB) && !ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) { - const float event_ofs[2] = { - vod->prev.event_xy[0] - x, - vod->prev.event_xy[1] - y, - }; + const float event_ofs[2] = { + vod->prev.event_xy[0] - x, + vod->prev.event_xy[1] - y, + }; + + if ((vod->rv3d->persp == RV3D_CAMOB) && !ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)) { ED_view3d_camera_view_pan(vod->region, event_ofs); } + else if (ED_view3d_offset_lock_check(vod->v3d, vod->rv3d)) { + vod->rv3d->ofs_lock[0] -= (event_ofs[0] * 2.0f) / (float)vod->region->winx; + vod->rv3d->ofs_lock[1] -= (event_ofs[1] * 2.0f) / (float)vod->region->winy; + } else { float dvec[3]; - float mval_f[2]; - mval_f[0] = x - vod->prev.event_xy[0]; - mval_f[1] = y - vod->prev.event_xy[1]; - ED_view3d_win_to_delta(vod->region, mval_f, dvec, vod->init.zfac); + ED_view3d_win_to_delta(vod->region, event_ofs, dvec, vod->init.zfac); - add_v3_v3(vod->rv3d->ofs, dvec); + sub_v3_v3(vod->rv3d->ofs, dvec); if (RV3D_LOCK_FLAGS(vod->rv3d) & RV3D_BOXVIEW) { view3d_boxview_sync(vod->area, vod->region); -- cgit v1.2.3