Node Wrangler: Improved accuracy on Align Nodes operator #104551
No reviewers
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#104551
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "quackarooni/blender-addons:nw_rework_align_nodes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary of the issue:
The Align Nodes operator for Node Wrangler –
NWAlignNodes
, was intended to evenly space nodes such that their midpoints lie in the same horizontal/vertical line. However, due to edge cases not considered by the code, it is often very easy to run into situations where the nodes are not properly aligned. Nodes inside frames, hidden nodes, reroutes, or any combination of those three would usually lead to inaccurate alignments, as they were not being considered by the original code.Implemented solution:
This PR addresses that by having different midpoint calculations to handle hidden nodes and reroutes. As for framed nodes, a context manager was implemented to temporarily unframe them, do the alignment, and put them back again to their parent frames.
User-facing changes:
Addtionally, the process of improving the calculation logic also led to tweaks in the UI. One of these was adding a selection length check into the operator's
poll
function which grays out the operator buttons when not enough nodes are selected. This also had the effect of preventing an arguably very unintuitive behavior where an empty selection gets treated as if all nodes are selected.(It isn't a bug, but rather deliberately coded in the operator. Arguably it saves a keystroke from having to select all nodes, but just leads to confusion especially in the previously mentioned edge cases where the alignment calculations were also broken - see #99904)
Other UI changes include exposing alignment axis options in the context menu and N-panel, and having the margin properties that are configurable in the preference menu.
Documentation:
Comparison of old and new operator behavior
Documentation:
UI Changes from this patch
Not really a review, but:
Testing:
The blend file below contains all the test scenes shown above, along with a script that spawns a panel which allows for easy cross-comparisons between the old and new versions of the operator.
@pioverfour thanks, I appreciate the feedback!
I actually agree, personally that's what I also expect with the name 'Align Nodes' tbh.
The behavior is from the original code, my patch just takes care of the edge cases where it breaks.
Personally I think, "Distribute Nodes" is more in line to what the operator is actually doing, if the name is to be taken from 'Align and Distribute' operations you often see in softwares like Photoshop or Word.
Duly noted, was going back and forth myself on whether to go with a single or double column layout in the preferences. I guess double-column has the downside of obscuring some of the text if the prefs menu was on a small window.
Adjusting the preferences is something that I should be able to quickly address in this patch.
But renaming the operator from "Align Nodes" to "Distribute Nodes" would be something that'll entail changing a good amount of internal names, variables, labels, tooltips, etc., I wonder if that's out of scope for a PR like this and should be left to a later PR that'll focus mostly on that?
Yes, and also it feels like the options for the margin and merge node are related if they are next to each other. And you kind of lose the benefit of quickly scanning vertically. (But then again I know little about UI design so take this with a grain of salt!)
Oh, I thought it was new code since I couldn’t find these operators in the current UI. But if it’s from the original code, then it’s definitely out of scope :)
I've been working on a patch addressing the same issues and saw this PR only a few days ago. Now while re-evaluating if my patch is worth developing further I have two small notes for your PR:
Checkout
From your project repository, check out a new branch and test the changes.