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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user