[Bf-blender-cvs] [605e1841676] master: Cleanup: use const for transform internal API

Campbell Barton noreply at git.blender.org
Mon May 21 17:25:18 CEST 2018


Commit: 605e1841676ce44de827d924a9e7f3e8d5f8b3dc
Author: Campbell Barton
Date:   Mon May 21 17:24:14 2018 +0200
Branches: master
https://developer.blender.org/rB605e1841676ce44de827d924a9e7f3e8d5f8b3dc

Cleanup: use const for transform internal API

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

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 6afdc7b208d..b1b1dd36bf0 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -775,7 +775,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]);
 
 void calculatePropRatio(TransInfo *t);
 
-void getViewVector(TransInfo *t, float coord[3], float vec[3]);
+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);
 
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 18d47eb9c3d..719a6e11ce7 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -169,7 +169,7 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3])
 	mul_m3_v3(t->con.mtx, vec);
 }
 
-static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
+static void viewAxisCorrectCenter(const TransInfo *t, float t_con_center[3])
 {
 	if (t->spacetype == SPACE_VIEW3D) {
 		// View3D *v3d = t->sa->spacedata.first;
@@ -193,7 +193,10 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
 	}
 }
 
-static void axisProjection(TransInfo *t, const float axis[3], const float in[3], float out[3])
+/**
+ * Axis calculation taking the view into account, correcting view-aligned axis.
+ */
+static void axisProjection(const TransInfo *t, const float axis[3], const float in[3], float out[3])
 {
 	float norm[3], vec[3], factor, angle;
 	float t_con_center[3];
@@ -211,12 +214,11 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
 	if (angle > (float)M_PI_2) {
 		angle = (float)M_PI - angle;
 	}
-	angle = RAD2DEGF(angle);
 
 	/* For when view is parallel to constraint... will cause NaNs otherwise
 	 * So we take vertical motion in 3D space and apply it to the
 	 * constraint axis. Nice for camera grab + MMB */
-	if (angle < 5.0f) {
+	if (angle < DEG2RADF(5.0f)) {
 		project_v3_v3v3(vec, in, t->viewinv[1]);
 		factor = dot_v3v3(t->viewinv[1], vec) * 2.0f;
 		/* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
@@ -275,7 +277,7 @@ static void axisProjection(TransInfo *t, const float axis[3], const float in[3],
  * Return true if the 2x axis are both aligned when projected into the view.
  * In this case, we can't usefully project the cursor onto the plane.
  */
-static bool isPlaneProjectionViewAligned(TransInfo *t)
+static bool isPlaneProjectionViewAligned(const TransInfo *t)
 {
 	const float eps = 0.001f;
 	const float *constraint_vector[2];
@@ -301,7 +303,7 @@ static bool isPlaneProjectionViewAligned(TransInfo *t)
 	return fabsf(factor) < eps;
 }
 
-static void planeProjection(TransInfo *t, const float in[3], float out[3])
+static void planeProjection(const TransInfo *t, const float in[3], float out[3])
 {
 	float vec[3], factor, norm[3];
 
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index be6067f9c2d..ad88bbe53f4 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -109,7 +109,7 @@
 
 /* ************************** Functions *************************** */
 
-void getViewVector(TransInfo *t, float coord[3], float vec[3])
+void getViewVector(const TransInfo *t, const float coord[3], float vec[3])
 {
 	if (t->persp != RV3D_ORTHO) {
 		sub_v3_v3v3(vec, coord, t->viewinv[3]);



More information about the Bf-blender-cvs mailing list