[Bf-blender-cvs] [9be49a10699] blender-v3.0-release: Fix: Property editor icon jittering in some cases

Leon Leno noreply at git.blender.org
Fri Nov 5 22:32:55 CET 2021


Commit: 9be49a10699417aa5902144d99ff70e5e1fc6af8
Author: Leon Leno
Date:   Fri Nov 5 16:32:35 2021 -0500
Branches: blender-v3.0-release
https://developer.blender.org/rB9be49a10699417aa5902144d99ff70e5e1fc6af8

Fix: Property editor icon jittering in some cases

In the tools tab, the tool icon would be offset when it intersected
the bottom of the editor. With some screen resolutions, the icons on
the left side of the editor would also move when intersecting the
bottom of the editor. This happened because of the truncation in
the implicit conversion from float to int. Instead, use explicit
conversion functions.

Differential Revision: https://developer.blender.org/D11097

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

M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_widgets.c

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

diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 5784af90834..c1dd4fcb4e4 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1503,7 +1503,8 @@ static void icon_draw_rect(float x,
   int draw_w = w;
   int draw_h = h;
   int draw_x = x;
-  int draw_y = y;
+  /* We need to round y, to avoid the icon jittering in some cases. */
+  int draw_y = round_fl_to_int(y);
 
   /* sanity check */
   if (w <= 0 || h <= 0 || w > 2000 || h > 2000) {
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 4b11ed61657..7d1b7b80ccd 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1407,8 +1407,8 @@ static void widget_draw_icon(
 
     /* force positions to integers, for zoom levels near 1. draws icons crisp. */
     if (aspect > 0.95f && aspect < 1.05f) {
-      xs = (int)(xs + 0.1f);
-      ys = (int)(ys + 0.1f);
+      xs = roundf(xs);
+      ys = roundf(ys);
     }
 
     /* Get theme color. */



More information about the Bf-blender-cvs mailing list