[Bf-blender-cvs] [9042532085a] blender-v2.92-release: Cleanup: Move and rename 'getViewVector' utility

Germano Cavalcante noreply at git.blender.org
Wed Feb 3 18:55:15 CET 2021


Commit: 9042532085ad8f9d08a94b210c92f89a1cb58013
Author: Germano Cavalcante
Date:   Wed Feb 3 14:01:40 2021 -0300
Branches: blender-v2.92-release
https://developer.blender.org/rB9042532085ad8f9d08a94b210c92f89a1cb58013

Cleanup: Move and rename 'getViewVector' utility

This function is only being used by the constraint code.

===================================================================

M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_constraints.c
M	source/blender/editors/transform/transform_generics.c

===================================================================

diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 91bf2bf8aac..fff7d47cc5b 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -722,8 +722,6 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]);
 
 void calculatePropRatio(TransInfo *t);
 
-void getViewVector(const TransInfo *t, const float coord[3], float vec[3]);
-
 void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot);
 
 void freeCustomNormalArray(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 78d3f213102..96671697dc4 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -79,6 +79,17 @@ 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
 
@@ -218,14 +229,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);
@@ -342,7 +353,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;
@@ -353,7 +364,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);
 
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 504a15b520c..f648369bc31 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -64,19 +64,6 @@
 #include "transform_orientations.h"
 #include "transform_snap.h"
 
-/* ************************** Functions *************************** */
-
-void getViewVector(const TransInfo *t, const float coord[3], float vec[3])
-{
-  if (t->persp != RV3D_ORTHO) {
-    sub_v3_v3v3(vec, t->viewinv[3], coord);
-  }
-  else {
-    copy_v3_v3(vec, t->viewinv[2]);
-  }
-  normalize_v3(vec);
-}
-
 /* ************************** GENERICS **************************** */
 
 void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options)



More information about the Bf-blender-cvs mailing list