diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-02-03 20:57:06 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-02-03 20:57:06 +0300 |
commit | 9d902d1b30f828d6861e38a3afd068ec5dcecd21 (patch) | |
tree | ff2a7ff90ad59b18f54d82d7d1bc2c80f33c40cd /source/blender/editors/transform/transform_constraints.c | |
parent | dcb2821292f962951e88f146cb304160f21f73da (diff) | |
parent | 5eb5a7f4b7d7c5228ec9596b35e7f2e317aad97d (diff) |
Merge branch 'blender-v2.92-release'
# Conflicts:
# source/blender/editors/transform/transform_constraints.c
Diffstat (limited to 'source/blender/editors/transform/transform_constraints.c')
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 09d3a991cc1..fc8e823f050 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -83,6 +83,18 @@ static void projection_matrix_calc(const TransInfo *t, float r_pmtx[3][3]) mul_m3_m3m3(r_pmtx, t->spacemtx, mat); } +static void view_vector_calc(const TransInfo *t, const float focus[3], float r_vec[3]) +{ + if (t->persp != RV3D_ORTHO) { + sub_v3_v3v3(r_vec, t->viewinv[3], focus); + } + else { + copy_v3_v3(r_vec, t->viewinv[2]); + } + normalize_v3(r_vec); +} + +/* ************************** CONSTRAINTS ************************* */ #define CONSTRAIN_EPSILON 0.0001f static void constraint_plane_calc(TransInfo *t, float r_plane[4]) @@ -221,14 +233,14 @@ static void axisProjection(const TransInfo *t, float norm_center[3]; float plane[3]; - getViewVector(t, t_con_center, norm_center); + view_vector_calc(t, t_con_center, norm_center); cross_v3_v3v3(plane, norm_center, axis); project_v3_v3v3(vec, in, plane); sub_v3_v3v3(vec, in, vec); add_v3_v3v3(v, vec, t_con_center); - getViewVector(t, v, norm); + view_vector_calc(t, v, norm); /* give arbitrary large value if projection is impossible */ factor = dot_v3v3(axis, norm); @@ -345,7 +357,7 @@ static bool isPlaneProjectionViewAligned(const TransInfo *t, const float plane[4 { const float eps = 0.001f; float view_to_plane[3]; - getViewVector(t, t->center_global, view_to_plane); + view_vector_calc(t, t->center_global, view_to_plane); float factor = dot_v3v3(plane, view_to_plane); return fabsf(factor) < eps; @@ -356,7 +368,7 @@ static void planeProjection(const TransInfo *t, const float in[3], float out[3]) float vec[3], factor, norm[3]; add_v3_v3v3(vec, in, t->center_global); - getViewVector(t, vec, norm); + view_vector_calc(t, vec, norm); sub_v3_v3v3(vec, out, in); @@ -561,7 +573,9 @@ static void constraints_rotation_imp(TransInfo *t, } /* don't flip axis if asked to or if num input */ if (r_angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) { - if (dot_v3v3(r_vec, t->viewinv[2]) > 0.0f) { + float view_vector[3]; + view_vector_calc(t, t->center_global, view_vector); + if (dot_v3v3(r_vec, view_vector) > 0.0f) { *r_angle = -(*r_angle); } } |