[Bf-blender-cvs] [1802d14394c] master: Fix T53463: Rotation numerical input shows instable behaviour.

Bastien Montagne noreply at git.blender.org
Mon Dec 4 18:41:58 CET 2017


Commit: 1802d14394c52698c0501e03179a651cf3a65cfd
Author: Bastien Montagne
Date:   Mon Dec 4 18:40:33 2017 +0100
Branches: master
https://developer.blender.org/rB1802d14394c52698c0501e03179a651cf3a65cfd

Fix T53463: Rotation numerical input shows instable behaviour.

Inverting a number in radians when user is in degrees gives rather
unexpected results. ;)

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

M	source/blender/editors/util/numinput.c

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

diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index 61142fdc887..0f3240946fd 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -488,8 +488,9 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 		const float fac = (float)BKE_scene_unit_scale(&sce->unit, n->unit_type[idx], 1.0);
 
 		/* Make radian default unit when needed. */
-		if (n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION)
+		if (n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION) {
 			default_unit = "r";
+		}
 
 		BLI_strncpy(str_unit_convert, n->str, sizeof(str_unit_convert));
 
@@ -513,7 +514,16 @@ bool handleNumInput(bContext *C, NumInput *n, const wmEvent *event)
 			n->val[idx] = -n->val[idx];
 		}
 		if (n->val_flag[idx] & NUM_INVERSE) {
-			n->val[idx] = 1.0f / n->val[idx];
+			val = n->val[idx];
+			/* If we invert on radians when user is in degrees, you get unexpected results... See T53463. */
+			if (!n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION) {
+				val = RAD2DEG(val);
+			}
+			val = 1.0 / val;
+			if (!n->unit_use_radians && n->unit_type[idx] == B_UNIT_ROTATION) {
+				val = DEG2RAD(val);
+			}
+			n->val[idx] = (float)val;
 		}
 
 		if (UNLIKELY(!isfinite(n->val[idx]))) {



More information about the Bf-blender-cvs mailing list