Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-02-18 09:16:05 +0300
committerCampbell Barton <campbell@blender.org>2022-02-18 09:24:10 +0300
commitca1f879c0254ba40188a7cdd40f564b12a82cd43 (patch)
tree6a395882b251683ac73f5316eedf657b0ace1b62 /source/blender/editors/space_view3d/view3d_navigate.c
parent51975b89edfcc02131f1f8248e1b3442ea2778fa (diff)
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.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_navigate.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate.c26
1 files changed, 12 insertions, 14 deletions
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);