From d5c9b509ec0e06318186f25212ffb2ba12177692 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 8 Jan 2014 17:04:10 +0100 Subject: Fix issues with float precision in numinput, like 'R 123' who would show additional 'noise' digits. Expose float precision helper in UI_interface.h API, so that numinput can use this helper as numbuttons already do. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D186 --- source/blender/editors/util/numinput.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/util/numinput.c') diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 2828973e91d..b9459d57f26 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -45,6 +45,7 @@ #endif #include "ED_numinput.h" +#include "UI_interface.h" /* NumInput.val_flag[] */ @@ -80,13 +81,15 @@ void outputNumInput(NumInput *n, char *str) { short i, j; const int ln = NUM_STR_REP_LEN; - const int prec = 4; /* draw-only, and avoids too much issues with radian->degrees conversion. */ + int prec = 2; /* draw-only, and avoids too much issues with radian->degrees conversion. */ for (j = 0; j <= n->idx_max; j++) { /* if AFFECTALL and no number typed and cursor not on number, use first number */ i = (n->flag & NUM_AFFECT_ALL && n->idx != j && !(n->val_flag[j] & NUM_EDITED)) ? 0 : j; if (n->val_flag[i] & NUM_EDITED) { + /* Get the best precision, allows us to draw '10.0001' as '10' instead! */ + prec = uiFloatPrecisionCalc(prec, (double)n->val[i]); if (i == n->idx) { const char *heading_exp = "", *trailing_exp = ""; char before_cursor[NUM_STR_REP_LEN]; -- cgit v1.2.3