Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-07-08 15:56:42 +0400
committerTon Roosendaal <ton@blender.org>2006-07-08 15:56:42 +0400
commit8a34cbe41ff8248aa9d65d0032f1ebcee87b1dff (patch)
treeb5f3e30d28da302a03f4fe0c3396a186a85a4301 /source
parent9587430c10c0fb2120cd0a6257e245e83edf06e9 (diff)
Bug fix #4627
The transform number input code allowed to keep typing forever. That's nice but the code uses floats to store values, so there's a limit of 7 digits resolution to take care of. I've added this limit now, it will stop when the 8th digit was typed, giving a range of 100 million, quite OK for Blender measures. There was also a short in use for values between 0 and 1, causing an error when you try to type like 0.99999. Here I've added a limit of 7 digits.
Diffstat (limited to 'source')
-rwxr-xr-xsource/blender/src/transform_numinput.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/source/blender/src/transform_numinput.c b/source/blender/src/transform_numinput.c
index 28a45bf94ca..c59fc8d6104 100755
--- a/source/blender/src/transform_numinput.c
+++ b/source/blender/src/transform_numinput.c
@@ -30,11 +30,13 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-#include <stdio.h> /* for sprintf */
+#include <math.h> /* fabs */
+#include <stdio.h> /* for sprintf */
-#include "BKE_global.h" /* for G */
+#include "BKE_global.h" /* for G */
+#include "BKE_utildefines.h" /* ABS */
-#include "mydevice.h" /* for KEY defines */
+#include "mydevice.h" /* for KEY defines */
#include "transform.h"
@@ -219,7 +221,8 @@ char handleNumInput(NumInput *n, unsigned short event)
if (!n->ctrl[idx])
n->ctrl[idx] = 1;
- if (n->ctrl[idx] == 1) {
+ if (fabs(n->val[idx]) > 9999999.0f);
+ else if (n->ctrl[idx] == 1) {
n->val[idx] *= 10;
n->val[idx] += Val;
}
@@ -228,13 +231,19 @@ char handleNumInput(NumInput *n, unsigned short event)
n->val[idx] -= Val;
}
else {
- n->val[idx] += Val / (float)n->ctrl[idx];
- n->ctrl[idx] *= 10;
+ /* float resolution breaks when over six digits after comma */
+ if( ABS(n->ctrl[idx]) < 10000000) {
+ n->val[idx] += Val / (float)n->ctrl[idx];
+ n->ctrl[idx] *= 10;
+ }
}
break;
default:
return 0;
}
+
+ printf("value %f cntrl %d\n", n->val[idx], n->ctrl[idx]);
+
/* REDRAW SINCE NUMBERS HAVE CHANGED */
return 1;
}