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-03-01 02:56:28 +0300
committerCampbell Barton <campbell@blender.org>2022-03-01 03:18:17 +0300
commiteb0f8317e231c4a02940d0269125a96a47e94c7e (patch)
tree03c67854c72c5a4507f22f8c2321c14b2629fccd /source/blender/editors/transform
parentae6400cfb4cae798667eab903d9c463fdec31298 (diff)
Cleanup: ED_view3d_win_to_delta & ED_view3d_calc_zfac usage
- Rename ED_view3d_win_to_delta `mval` argument to `xy_delta` as it as it was misleading since this is an screen-space offset not a region relative cursor position (typical use of the name `mval`). Also rename the variable passed to this function which also used the term `mval` in many places. - Re-order the output argument of ED_view3d_win_to_delta last. use an r_ prefix for return arguments. - Document how the `zfac` argument is intended to be used. - Split ED_view3d_calc_zfac into two functions as the `r_flip` argument was only used in some special cases.
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r--source/blender/editors/transform/transform.c4
-rw-r--r--source/blender/editors/transform/transform_constraints.c3
-rw-r--r--source/blender/editors/transform/transform_generics.c17
-rw-r--r--source/blender/editors/transform/transform_mode_vert_slide.c14
4 files changed, 18 insertions, 20 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index b006b13d217..67b0d5c85ac 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -177,8 +177,8 @@ void convertViewVec(TransInfo *t, float r_vec[3], double dx, double dy)
r_vec[1] = dy;
}
else {
- const float mval_f[2] = {(float)dx, (float)dy};
- ED_view3d_win_to_delta(t->region, mval_f, r_vec, t->zfac);
+ const float xy_delta[2] = {(float)dx, (float)dy};
+ ED_view3d_win_to_delta(t->region, xy_delta, t->zfac, r_vec);
}
}
else if (t->spacetype == SPACE_IMAGE) {
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 64ef170a13f..81b35e4539b 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -1041,8 +1041,7 @@ static void setNearestAxis3d(TransInfo *t)
* and to overflow the short integers.
* The formula used is a bit stupid, just a simplification of the subtraction
* of two 2D points 30 pixels apart (that's the last factor in the formula) after
- * projecting them with ED_view3d_win_to_delta and then get the length of that vector.
- */
+ * projecting them with #ED_view3d_win_to_delta and then get the length of that vector. */
zfac = mul_project_m4_v3_zfac(t->persmat, t->center_global);
zfac = len_v3(t->persinv[0]) * 2.0f / t->region->winx * zfac * 30.0f;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 2b523461800..8987325145c 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1146,7 +1146,7 @@ void calculateCenter(TransInfo *t)
projectFloatView(t, axis, t->center2d);
- /* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */
+ /* Rotate only needs correct 2d center, grab needs #ED_view3d_calc_zfac() value. */
if (t->mode == TFM_TRANSLATION) {
copy_v3_v3(t->center_global, axis);
}
@@ -1155,17 +1155,16 @@ void calculateCenter(TransInfo *t)
}
if (t->spacetype == SPACE_VIEW3D) {
- /* ED_view3d_calc_zfac() defines a factor for perspective depth correction,
- * used in ED_view3d_win_to_delta() */
+ /* #ED_view3d_calc_zfac() defines a factor for perspective depth correction,
+ * used in #ED_view3d_win_to_delta(). */
- /* zfac is only used convertViewVec only in cases operator was invoked in RGN_TYPE_WINDOW
- * and never used in other cases.
+ /* NOTE: `t->zfac` is only used #convertViewVec only in cases operator was invoked in
+ * #RGN_TYPE_WINDOW and never used in other cases.
*
- * We need special case here as well, since ED_view3d_calc_zfac will crash when called
- * for a region different from RGN_TYPE_WINDOW.
- */
+ * We need special case here as well, since #ED_view3d_calc_zfac will crash when called
+ * for a region different from #RGN_TYPE_WINDOW. */
if (t->region->regiontype == RGN_TYPE_WINDOW) {
- t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global, NULL);
+ t->zfac = ED_view3d_calc_zfac(t->region->regiondata, t->center_global);
}
else {
t->zfac = 0.0f;
diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c
index 0afc527d4a8..77c5707d814 100644
--- a/source/blender/editors/transform/transform_mode_vert_slide.c
+++ b/source/blender/editors/transform/transform_mode_vert_slide.c
@@ -146,9 +146,9 @@ static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2]
* by finding the closest edge in local-space.
* However this skews the outcome with non-uniform-scale. */
- /* first get the direction of the original mouse position */
+ /* First get the direction of the original mouse position. */
sub_v2_v2v2(dir, imval_fl, mval_fl);
- ED_view3d_win_to_delta(t->region, dir, dir, t->zfac);
+ ED_view3d_win_to_delta(t->region, dir, t->zfac, dir);
normalize_v3(dir);
for (i = 0, sv = sld->sv; i < sld->totsv; i++, sv++) {
@@ -425,18 +425,18 @@ void drawVertSlide(TransInfo *t)
/* direction from active vertex! */
if ((t->mval[0] != t->mouse.imval[0]) || (t->mval[1] != t->mouse.imval[1])) {
float zfac;
- float mval_ofs[2];
+ float xy_delta[2];
float co_orig_3d[3];
float co_dest_3d[3];
- mval_ofs[0] = t->mval[0] - t->mouse.imval[0];
- mval_ofs[1] = t->mval[1] - t->mouse.imval[1];
+ xy_delta[0] = t->mval[0] - t->mouse.imval[0];
+ xy_delta[1] = t->mval[1] - t->mouse.imval[1];
mul_v3_m4v3(
co_orig_3d, TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat, curr_sv->co_orig_3d);
- zfac = ED_view3d_calc_zfac(t->region->regiondata, co_orig_3d, NULL);
+ zfac = ED_view3d_calc_zfac(t->region->regiondata, co_orig_3d);
- ED_view3d_win_to_delta(t->region, mval_ofs, co_dest_3d, zfac);
+ ED_view3d_win_to_delta(t->region, xy_delta, zfac, co_dest_3d);
invert_m4_m4(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->imat,
TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat);