Nodes: Use index instead of reordering for draw order #113419

Merged
Hans Goudey merged 1 commits from HooglyBoogly/blender:node-no-reorder into main 2023-10-10 10:58:02 +02:00
Member

Currently nodes are reordered so that the "on top" nodes are last in the
list. Node order changing for simple operations like selection means we
either have to reevaluate the node tree data-block on selections or
accept that the evaluated order can be different from the original.
Currently we do the latter (see d76a0e98ba), but makes it
complex to refer to nodes by index, and is hard to reason about.

Instead of reordering nodes, store the ui order in the node itself
and sort the nodes before drawing them or doing any processing
that depends on the "depth."

The "selected_nodes" list in the context is no longer ordered by the
recent selection.

Currently nodes are reordered so that the "on top" nodes are last in the list. Node order changing for simple operations like selection means we either have to reevaluate the node tree data-block on selections or accept that the evaluated order can be different from the original. Currently we do the latter (see d76a0e98baecfca4e691), but makes it complex to refer to nodes by index, and is hard to reason about. Instead of reordering nodes, store the ui order in the node itself and sort the nodes before drawing them or doing any processing that depends on the "depth." The "selected_nodes" list in the context is no longer ordered by the recent selection.
Hans Goudey added 1 commit 2023-10-08 18:30:13 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
7cb6e464bb
Nodes: Use index instead of reordering for draw order
Currently nodes are reordered so that the "on top" nodes are last in the
list. Node order changing for simple operations like selection means we
either have to reevaluate the node tree data-block on selections or
accept that the evaluated order can be different from the original.
Currently we do the latter (see d76a0e98ba), but makes it
complex to refer to nodes by index, and is hard to reason about.

Instead of reordering nodes, store the ui order in the node itself
and sort the nodes before drawing them or doing any processing
that depends on the "depth."
Hans Goudey requested review from Jacques Lucke 2023-10-08 18:30:22 +02:00
Hans Goudey added this to the Nodes & Physics project 2023-10-08 18:30:27 +02:00
Author
Member

@blender-bot build

@blender-bot build
Jacques Lucke approved these changes 2023-10-08 19:58:53 +02:00
@ -1072,3 +1072,3 @@
if (CTX_data_equals(member, "selected_nodes")) {
if (snode->edittree) {
LISTBASE_FOREACH_BACKWARD (bNode *, node, &snode->edittree->nodes) {
for (bNode *node : snode->edittree->all_nodes()) {
Member

Looks like it was an intentional choice to add the nodes in a specific order to the list. I'm fine with changing it, but that should be mentioned in the commit. Also it may be necessary to expose the ui_order in rna. Addons also need the ability to figure out which order nodes are drawn in for some modal operators.

You could also try to figure when the order of nodes in context.selected_nodes became more explicit. Maybe some code relies on that currently.

Looks like it was an intentional choice to add the nodes in a specific order to the list. I'm fine with changing it, but that should be mentioned in the commit. Also it may be necessary to expose the `ui_order` in rna. Addons also need the ability to figure out which order nodes are drawn in for some modal operators. You could also try to figure when the order of nodes in `context.selected_nodes` became more explicit. Maybe some code relies on that currently.
Author
Member

I didn't see any code relying on this. I'll expose the ui_order in a follow-up PR, I agree that would be helpful.

I didn't see any code relying on this. I'll expose the `ui_order` in a follow-up PR, I agree that would be helpful.
Hans Goudey merged commit 1ccba4d9fe into main 2023-10-10 10:58:02 +02:00
Hans Goudey deleted branch node-no-reorder 2023-10-10 10:58:04 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
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 Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113419
No description provided.