From e6260ac9f5b174fddbd49fee80ce41c4e4a1c680 Mon Sep 17 00:00:00 2001 From: Habib Gahbiche Date: Mon, 10 Feb 2025 17:56:22 +0100 Subject: [PATCH] Fix #134107: Snapping while resizing nodes not working The grid size varied depending on the UI scale. This caused unintended behavior with snapping while resizing nodes. Pull Request: https://projects.blender.org/blender/blender/pulls/134123 --- source/blender/editors/space_node/node_edit.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 683b180e2a4..533ea703449 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -1016,10 +1016,12 @@ wmKeyMap *node_resize_modal_keymap(wmKeyConfig *keyconf) return keymap; } -/* Compute the nearest 1D coordinate corresponding to the nearest grid in node. */ +/* Compute the nearest 1D coordinate corresponding to the nearest grid in node editors. */ static float nearest_node_grid_coord(float co) { - float grid_size = grid_size_get(); + /* Size and location of nodes are independent of UI scale, so grid size should be independent of + * UI scale as well. */ + float grid_size = grid_size_get() / UI_SCALE_FAC; float rest = fmod(co, grid_size); float offset = rest - grid_size / 2 >= 0 ? grid_size : 0;