Cleanup: use _new as a suffix for viewport calculation

Both were used, prefer the suffix as it fits better with
other names used in the code such as `dist_{min/max/old}`.
This commit is contained in:
Campbell Barton
2025-05-07 10:33:42 +10:00
parent b83fe22703
commit 8dccfd2f8b
4 changed files with 34 additions and 34 deletions

View File

@@ -101,8 +101,8 @@ static void view3d_from_minmax(bContext *C,
ED_view3d_smooth_view_force_finish(C, v3d, region);
/* SMOOTHVIEW */
float new_ofs[3];
float new_dist;
float ofs_new[3];
float dist_new;
sub_v3_v3v3(afm, max, min);
size = max_fff(afm[0], afm[1], afm[2]);
@@ -131,21 +131,21 @@ static void view3d_from_minmax(bContext *C,
if (do_zoom) {
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
new_dist = ED_view3d_radius_to_dist(
dist_new = ED_view3d_radius_to_dist(
v3d, region, depsgraph, persp, true, (size / 2) * VIEW3D_MARGIN);
if (rv3d->is_persp) {
/* don't zoom closer than the near clipping plane */
new_dist = max_ff(new_dist, v3d->clip_start * 1.5f);
dist_new = max_ff(dist_new, v3d->clip_start * 1.5f);
}
}
}
mid_v3_v3v3(new_ofs, min, max);
negate_v3(new_ofs);
mid_v3_v3v3(ofs_new, min, max);
negate_v3(ofs_new);
V3D_SmoothParams sview = {nullptr};
sview.ofs = new_ofs;
sview.dist = do_zoom ? &new_dist : nullptr;
sview.ofs = ofs_new;
sview.dist = do_zoom ? &dist_new : nullptr;
/* The caller needs to use undo begin/end calls. */
sview.undo_str = nullptr;

View File

@@ -33,11 +33,11 @@ static wmOperatorStatus viewcenter_cursor_exec(bContext *C, wmOperator *op)
ED_view3d_smooth_view_force_finish(C, v3d, region);
/* non camera center */
float new_ofs[3];
negate_v3_v3(new_ofs, scene->cursor.location);
float ofs_new[3];
negate_v3_v3(ofs_new, scene->cursor.location);
V3D_SmoothParams sview = {nullptr};
sview.ofs = new_ofs;
sview.ofs = ofs_new;
sview.undo_str = op->type->name;
ED_view3d_smooth_view(C, v3d, region, smooth_viewtx, &sview);

View File

@@ -28,7 +28,7 @@ static wmOperatorStatus viewcenter_pick_invoke(bContext *C, wmOperator *op, cons
if (rv3d) {
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
float new_ofs[3];
float ofs_new[3];
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
ED_view3d_smooth_view_force_finish(C, v3d, region);
@@ -38,18 +38,18 @@ static wmOperatorStatus viewcenter_pick_invoke(bContext *C, wmOperator *op, cons
/* Ensure the depth buffer is updated for #ED_view3d_autodist. */
ED_view3d_depth_override(depsgraph, region, v3d, nullptr, V3D_DEPTH_NO_GPENCIL, true, nullptr);
if (ED_view3d_autodist(region, v3d, event->mval, new_ofs, nullptr)) {
if (ED_view3d_autodist(region, v3d, event->mval, ofs_new, nullptr)) {
/* pass */
}
else {
/* fallback to simple pan */
negate_v3_v3(new_ofs, rv3d->ofs);
ED_view3d_win_to_3d_int(v3d, region, new_ofs, event->mval, new_ofs);
negate_v3_v3(ofs_new, rv3d->ofs);
ED_view3d_win_to_3d_int(v3d, region, ofs_new, event->mval, ofs_new);
}
negate_v3(new_ofs);
negate_v3(ofs_new);
V3D_SmoothParams sview = {nullptr};
sview.ofs = new_ofs;
sview.ofs = ofs_new;
sview.undo_str = op->type->name;
ED_view3d_smooth_view(C, v3d, region, smooth_viewtx, &sview);

View File

@@ -40,8 +40,8 @@ static wmOperatorStatus view3d_zoom_border_exec(bContext *C, wmOperator *op)
float dist_range[2];
/* SMOOTHVIEW */
float new_dist;
float new_ofs[3];
float dist_new;
float ofs_new[3];
/* ZBuffer depth vars */
float depth_close = FLT_MAX;
@@ -108,12 +108,12 @@ static wmOperatorStatus view3d_zoom_border_exec(bContext *C, wmOperator *op)
}
sub_v3_v3v3(dvec, p, p_corner);
negate_v3_v3(new_ofs, p);
negate_v3_v3(ofs_new, p);
new_dist = len_v3(dvec);
dist_new = len_v3(dvec);
/* Account for the lens, without this a narrow lens zooms in too close. */
new_dist *= (v3d->lens / DEFAULT_SENSOR_WIDTH);
dist_new *= (v3d->lens / DEFAULT_SENSOR_WIDTH);
/* ignore dist_range min */
dist_range[0] = v3d->clip_start * 1.5f;
@@ -123,23 +123,23 @@ static wmOperatorStatus view3d_zoom_border_exec(bContext *C, wmOperator *op)
vb[0] = region->winx;
vb[1] = region->winy;
new_dist = rv3d->dist;
dist_new = rv3d->dist;
/* convert the drawn rectangle into 3d space */
if (depth_close != FLT_MAX && ED_view3d_unproject_v3(region, cent[0], cent[1], depth_close, p))
{
negate_v3_v3(new_ofs, p);
negate_v3_v3(ofs_new, p);
}
else {
float xy_delta[2];
float zfac;
/* We can't use the depth, fallback to the old way that doesn't set the center depth */
copy_v3_v3(new_ofs, rv3d->ofs);
copy_v3_v3(ofs_new, rv3d->ofs);
{
float tvec[3];
negate_v3_v3(tvec, new_ofs);
negate_v3_v3(tvec, ofs_new);
zfac = ED_view3d_calc_zfac(rv3d, tvec);
}
@@ -147,23 +147,23 @@ static wmOperatorStatus view3d_zoom_border_exec(bContext *C, wmOperator *op)
xy_delta[1] = (rect.ymin + rect.ymax - vb[1]) / 2.0f;
ED_view3d_win_to_delta(region, xy_delta, zfac, dvec);
/* center the view to the center of the rectangle */
sub_v3_v3(new_ofs, dvec);
sub_v3_v3(ofs_new, dvec);
}
/* work out the ratios, so that everything selected fits when we zoom */
xscale = (BLI_rcti_size_x(&rect) / vb[0]);
yscale = (BLI_rcti_size_y(&rect) / vb[1]);
new_dist *= max_ff(xscale, yscale);
dist_new *= max_ff(xscale, yscale);
}
if (!zoom_in) {
sub_v3_v3v3(dvec, new_ofs, rv3d->ofs);
new_dist = rv3d->dist * (rv3d->dist / new_dist);
add_v3_v3v3(new_ofs, rv3d->ofs, dvec);
sub_v3_v3v3(dvec, ofs_new, rv3d->ofs);
dist_new = rv3d->dist * (rv3d->dist / dist_new);
add_v3_v3v3(ofs_new, rv3d->ofs, dvec);
}
/* clamp after because we may have been zooming out */
CLAMP(new_dist, dist_range[0], dist_range[1]);
CLAMP(dist_new, dist_range[0], dist_range[1]);
const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d);
if (rv3d->persp == RV3D_CAMOB) {
@@ -176,8 +176,8 @@ static wmOperatorStatus view3d_zoom_border_exec(bContext *C, wmOperator *op)
}
}
V3D_SmoothParams sview_params = {};
sview_params.ofs = new_ofs;
sview_params.dist = &new_dist;
sview_params.ofs = ofs_new;
sview_params.dist = &dist_new;
sview_params.undo_str = op->type->name;
ED_view3d_smooth_view(C, v3d, region, smooth_viewtx, &sview_params);