Commit: f69c565a33ca58bb95a2bd22de0e211799508182
Author: Ramil Roosileht
Date:   Wed Jun 8 11:51:29 2022 -0700
Branches: master
https://developer.blender.org/rBf69c565a33ca58bb95a2bd22de0e211799508182

D15085: Fix numbers jumping in edit voxel size widget

Introduces an option for BKE_unit_value_as_string to skip stripping of zeroes, 
thus reducing flickering when using edit voxel size widget.

{F13125416}

Reviewed By: Julien Kaspar & Joseph Eagar
Differential Revision: https://developer.blender.org/D15085
Ref D15085

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

M       release/scripts/addons
M       source/blender/blenkernel/intern/unit.c
M       source/blender/editors/object/object_remesh.cc

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

diff --git a/release/scripts/addons b/release/scripts/addons
index d990559d7b1..c51e0bb1793 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit d990559d7b19593cbaff17ba59b8dd9d0d60e615
+Subproject commit c51e0bb1793c44c7a1b7435593dd5022cf7c8eec
diff --git a/source/blender/blenkernel/intern/unit.c 
b/source/blender/blenkernel/intern/unit.c
index 30e02e5411b..2520ce5179f 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -460,11 +460,19 @@ static size_t unit_as_string(char *str,
   }
 
   double value_conv = (value / unit->scalar) - unit->bias;
+  bool strip_skip;
 
   /* Adjust precision to expected number of significant digits.
    * Note that here, we shall not have to worry about very big/small numbers, 
units are expected
    * to replace 'scientific notation' in those cases. */
   prec -= integer_digits_d(value_conv);
+
+  /* Negative precision is used to disable stripping of zeroes. This reduces 
text jumping when changing values. */
+  if (prec < 0) {
+  strip_skip = true;
+  prec *= -1;
+  }
+
   CLAMP(prec, 0, 6);
 
   /* Convert to a string. */
@@ -478,8 +486,10 @@ static size_t unit_as_string(char *str,
   size_t i = len - 1;
 
   if (prec > 0) {
-    while (i > 0 && str[i] == '0') { /* 4.300 -> 4.3 */
-      str[i--] = pad;
+    if (!strip_skip) {
+      while (i > 0 && str[i] == '0') { /* 4.300 -> 4.3 */
+        str[i--] = pad;
+      }
     }
 
     if (i > 0 && str[i] == '.') { /* 10. -> 10 */
diff --git a/source/blender/editors/object/object_remesh.cc 
b/source/blender/editors/object/object_remesh.cc
index ba2efa6e517..71b757b66ff 100644
--- a/source/blender/editors/object/object_remesh.cc
+++ b/source/blender/editors/object/object_remesh.cc
@@ -344,7 +344,7 @@ static void voxel_size_edit_draw(const bContext *C, ARegion 
*UNUSED(ar), void *a
   BKE_unit_value_as_string(str,
                            VOXEL_SIZE_EDIT_MAX_STR_LEN,
                            (double)(cd->voxel_size * unit->scale_length),
-                           4,
+                           -3,
                            B_UNIT_LENGTH,
                            unit,
                            true);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to