[Bf-blender-cvs] [b94447a2981] master: Fix T92494: Node Editor dot grid not respecting display resolution scale

Philipp Oeser noreply at git.blender.org
Wed Oct 27 09:58:19 CEST 2021


Commit: b94447a298146f273c848541a3122afea001ba39
Author: Philipp Oeser
Date:   Tue Oct 26 12:33:36 2021 +0200
Branches: master
https://developer.blender.org/rBb94447a298146f273c848541a3122afea001ba39

Fix T92494: Node Editor dot grid not respecting display resolution scale

This seems wrong and was especially noticeable since transform snapping
does account for it (which was reported in T92494).
Now divide the `DotGridLevelInfo` `step_factor` by the default of 20 for
`U.widget_unit` and scale it later by the actual interface scale.

note: when zooming, this will still always snap to the smallest dot
level (not sure, with a bit more work it could be possible to only snap
to the lowest visible level after fading?)

Maniphest Tasks: T92494

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

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

M	source/blender/editors/interface/view2d.c

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

diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 3b6a7e1e88e..eea6512f0f8 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1324,15 +1324,15 @@ typedef struct DotGridLevelInfo {
 } DotGridLevelInfo;
 
 static const DotGridLevelInfo level_info[9] = {
-    {128.0f, -0.1f, 0.01f},
-    {64.0f, 0.0f, 0.025f},
-    {32.0f, 0.025f, 0.15f},
-    {16.0f, 0.05f, 0.2f},
-    {8.0f, 0.1f, 0.25f},
-    {4.0f, 0.125f, 0.3f},
-    {2.0f, 0.25f, 0.5f},
-    {1.0f, 0.7f, 0.9f},
-    {0.5f, 0.6f, 0.9f},
+    {6.4f, -0.1f, 0.01f},
+    {3.2f, 0.0f, 0.025f},
+    {1.6f, 0.025f, 0.15f},
+    {0.8f, 0.05f, 0.2f},
+    {0.4f, 0.1f, 0.25f},
+    {0.2f, 0.125f, 0.3f},
+    {0.1f, 0.25f, 0.5f},
+    {0.05f, 0.7f, 0.9f},
+    {0.025f, 0.6f, 0.9f},
 };
 
 /**
@@ -1363,7 +1363,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d,
 
   for (int level = 0; level < grid_levels; level++) {
     const DotGridLevelInfo *info = &level_info[level];
-    const float step = min_step * info->step_factor;
+    const float step = min_step * info->step_factor * U.widget_unit;
 
     const float alpha_factor = (zoom_normalized - info->fade_in_start_zoom) /
                                (info->fade_in_end_zoom - info->fade_in_start_zoom);



More information about the Bf-blender-cvs mailing list