Two in one:
[blender.git] / source / blender / src / transform_numinput.c
index 8ea83463bc0c80531074002df34635d224f7bc4a..730d25545bdf78602c0a5d109cc8f48bc70b4285 100755 (executable)
  * ***** 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"
 
@@ -81,6 +83,7 @@ void outputNumInput(NumInput *n, char *str)
                        case 1000:
                        case -1000:
                                sprintf(&str[j*20], "%.2f%c", n->val[i], cur);
+                               break;
                        case 10000:
                        case -10000:
                                sprintf(&str[j*20], "%.3f%c", n->val[i], cur);
@@ -218,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;
                }
@@ -227,13 +231,17 @@ 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;
        }
+       
        /* REDRAW SINCE NUMBERS HAVE CHANGED */
        return 1;
 }