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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user