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
This commit is contained in:
Habib Gahbiche
2025-02-10 17:56:22 +01:00
parent 9842ecb6b8
commit e6260ac9f5

View File

@@ -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;