[Bf-blender-cvs] [833ef0c] master: Transform input: don't change initial cursor value

Campbell Barton noreply at git.blender.org
Thu Nov 12 14:12:01 CET 2015


Commit: 833ef0cfdd0ac9154f018c17a80ca8cdc7c15bc9
Author: Campbell Barton
Date:   Thu Nov 12 22:58:35 2015 +1100
Branches: master
https://developer.blender.org/rB833ef0cfdd0ac9154f018c17a80ca8cdc7c15bc9

Transform input: don't change initial cursor value

Store previous coords in cursor data instead.

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

M	source/blender/editors/transform/transform_input.c

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

diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 16ce0cd..44779fc 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -163,20 +163,24 @@ static void InputCustomRatio(TransInfo *t, MouseInput *mi, const double mval[2],
 	output[0] = -output[0];
 }
 
+struct InputAngle_Data {
+	double angle;
+	double mval_prev[2];
+};
+
 static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2], float output[3])
 {
+	struct InputAngle_Data *data = mi->data;
 	double dx2 = mval[0] - mi->center[0];
 	double dy2 = mval[1] - mi->center[1];
 	double B = sqrt(dx2 * dx2 + dy2 * dy2);
 
-	double dx1 = mi->imval[0] - mi->center[0];
-	double dy1 = mi->imval[1] - mi->center[1];
+	double dx1 = data->mval_prev[0] - mi->center[0];
+	double dy1 = data->mval_prev[1] - mi->center[1];
 	double A = sqrt(dx1 * dx1 + dy1 * dy1);
 
-	double dx3 = mval[0] - mi->imval[0];
-	double dy3 = mval[1] - mi->imval[1];
-
-	double *angle = mi->data;
+	double dx3 = mval[0] - data->mval_prev[0];
+	double dy3 = mval[1] - data->mval_prev[1];
 
 	/* use doubles here, to make sure a "1.0" (no rotation) doesn't become 9.999999e-01, which gives 0.02 for acos */
 	double deler = (((dx1 * dx1 + dy1 * dy1) +
@@ -210,19 +214,12 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2
 		if ((dx1 * dy2 - dx2 * dy1) > 0.0) dphi = -dphi;
 	}
 
-	if (mi->precision) {
-		dphi = dphi * mi->precision_factor;
-	}
+	data->angle += ((double)dphi) * (mi->precision ? mi->precision_factor : 1.0f);
 
-	/* if no delta angle, don't update initial position */
-	if (dphi != 0) {
-		mi->imval[0] = mval[0];
-		mi->imval[1] = mval[1];
-	}
+	data->mval_prev[0] = mval[0];
+	data->mval_prev[1] = mval[1];
 
-	*angle += (double)dphi;
-
-	output[0] = *angle;
+	output[0] = data->angle;
 }
 
 static void InputAngleSpring(TransInfo *t, MouseInput *mi, const double mval[2], float output[3])
@@ -288,19 +285,24 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
 			t->helpline = HLP_SPRING;
 			break;
 		case INPUT_ANGLE:
-			mi->use_virtual_mval = false;
-			mi->precision_factor = 1.0f / 30.0f;
-			mi->data = MEM_callocN(sizeof(double), "angle accumulator");
-			mi->apply = InputAngle;
-			t->helpline = HLP_ANGLE;
-			break;
 		case INPUT_ANGLE_SPRING:
+		{
+			struct InputAngle_Data *data;
 			mi->use_virtual_mval = false;
-			calcSpringFactor(mi);
-			mi->data = MEM_callocN(sizeof(double), "angle accumulator");
-			mi->apply = InputAngleSpring;
+			mi->precision_factor = 1.0f / 30.0f;
+			data = MEM_callocN(sizeof(struct InputAngle_Data), "angle accumulator");
+			data->mval_prev[0] = mi->imval[0];
+			data->mval_prev[1] = mi->imval[1];
+			mi->data = data;
+			if (mode == INPUT_ANGLE) {
+				mi->apply = InputAngle;
+			}
+			else {
+				mi->apply = InputAngleSpring;
+			}
 			t->helpline = HLP_ANGLE;
 			break;
+		}
 		case INPUT_TRACKBALL:
 			mi->precision_factor = 1.0f / 30.0f;
 			/* factor has to become setting or so */




More information about the Bf-blender-cvs mailing list