Nodes: Improve matches when dragging a node onto a link #127868

Open
Charlie Jolly wants to merge 3 commits from CharlieJolly/blender:node-drag-link into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This patch adds a new 'get_main_socket_by_type' function to match
the node sockets more precisely when dragging a node onto
a pre-existing link.

This resolves some cases when nodes are unable to drag link when there
are suitable sockets available. E.g. a menu socket in a group node would
prevent the next available socket from being used.
This was previously investigated in #127717.

Previously, the get_main_socket function matched sockets as follows.

  1. Socket declaration is_default_link_socket flag
  2. Sockets matched by highest priority node socket*
  3. Validate link

The new function matches sockets as follows.

  1. Socket declaration is_default_link_socket flag (same as before)
  2. Sockets matched by exact type with link socket*
  3. Sockets matched by first lower type than link socket.*^
  4. Sockets matched by highest priority node socket* (same as before)
  5. Validate link (same as before)

*Visible node sockets, then hidden node sockets
^This is only for RGBA sockets and below.

Matching by name was not considered as it would have required
some hard coding of socket names.

Before After Comment
image image Node is now able to attach to the link by matching the type
image image Node is now able to attach
This patch adds a new 'get_main_socket_by_type' function to match the node sockets more precisely when dragging a node onto a pre-existing link. This resolves some cases when nodes are unable to drag link when there are suitable sockets available. E.g. a menu socket in a group node would prevent the next available socket from being used. This was previously investigated in #127717. Previously, the `get_main_socket` function matched sockets as follows. 1) Socket declaration `is_default_link_socket` flag 2) Sockets matched by highest priority node socket* 3) Validate link The new function matches sockets as follows. 1) Socket declaration `is_default_link_socket` flag (same as before) 2) Sockets matched by exact type with link socket* 3) Sockets matched by first lower type than link socket.*^ 4) Sockets matched by highest priority node socket* (same as before) 5) Validate link (same as before) *Visible node sockets, then hidden node sockets ^This is only for RGBA sockets and below. Matching by name was not considered as it would have required some hard coding of socket names. | Before | After | Comment | | -------- | -------- | -------- | | <img width="200" alt="image" src="attachments/25ac8c87-1111-4cbb-bbb0-5722386c7c10"> | <img width="200" alt="image" src="attachments/e85d1174-2e82-4cf9-9a05-efc3682471ca"> | Node is now able to attach to the link by matching the type | | <img width="200" alt="image" src="attachments/64ba63ad-cde4-479f-ac2f-bac1f3d53444"> | <img width="200" alt="image" src="attachments/1a189e3d-c047-4cf0-8fd8-52995c3e6c01"> | Node is now able to attach |
Charlie Jolly added 1 commit 2024-09-19 17:15:03 +02:00
This patch adds a new 'get_main_socket_by_type' function to match
the node sockets more precisely with the link.

This resolves some cases when nodes are unabel to drag link when there
are suitable sockets available. E.g. a menu socket in a group node would
prevent. This was previously investigated in #127717.

Previously, the `get_main_socket` function matched sockets as follows.
1) Socket declaration `is_default_link_socket` flag
2) Sockets matched by highest priority node socket*
3) Validate link

The new function matches sockets as follows.
1) Socket declaration `is_default_link_socket` flag (same as before)
2) Sockets matched by exact type with link socket*
3) Sockets matched by first lower type than link socket*
4) Sockets matched by highest priority node socket* (same as before)
5) Validate link (same as before)

* Visible node sockets, then hidden node sockets

Matching be name was not considered as it would have required
some hard coding of socket names.
Charlie Jolly added this to the Nodes & Physics project 2024-09-19 17:15:22 +02:00
Charlie Jolly modified the project from Nodes & Physics to User Interface 2024-09-19 17:15:27 +02:00
Charlie Jolly modified the project from User Interface to Nodes & Physics 2024-09-19 17:15:35 +02:00
Charlie Jolly added the
Interest
Nodes & Physics
Interest
User Interface
labels 2024-09-19 17:15:58 +02:00
Charlie Jolly changed title from Nodes: Improve matches when dragging a node onto a link to WIP: Nodes: Improve matches when dragging a node onto a link 2024-09-19 17:23:00 +02:00
Charlie Jolly changed title from WIP: Nodes: Improve matches when dragging a node onto a link to Nodes: Improve matches when dragging a node onto a link 2024-09-28 21:58:34 +02:00
Charlie Jolly added 1 commit 2024-10-01 22:05:49 +02:00
Merge branch 'main' into node-drag-link
Some checks failed
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-darwin-x86_64 Build done.
buildbot/vexp-code-patch-darwin-arm64 Build done.
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-linux-x86_64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
2b94c62823
Author
Member

Comments from module meeting: https://devtalk.blender.org/t/2024-10-01-nodes-physics-module-meeting/36875

Improve auto-linking a node when dragging on a link
Was hard to discuss during the meeting. Will just need more in depth testing to see what cases work or don’t work yet.

Comments from module meeting: https://devtalk.blender.org/t/2024-10-01-nodes-physics-module-meeting/36875 > Improve auto-linking a node when dragging on a link Was hard to discuss during the meeting. Will just need more in depth testing to see what cases work or don’t work yet.
Author
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR127868) when ready.
Charlie Jolly added 1 commit 2024-10-02 10:44:35 +02:00
Merge branch 'main' into node-drag-link
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
4751f78848
Author
Member

@blender-bot package windows-amd64

@blender-bot package windows-amd64
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR127868) when ready.
Charlie Jolly requested review from Simon Thommes 2024-10-02 12:55:00 +02:00
Iliya Katushenock reviewed 2024-10-02 17:28:08 +02:00
Iliya Katushenock left a comment
Member

My initial attemp was in https://archive.blender.org/developer/D16684
Current thought about direction:

  1. Move internal links generation to generic bNodeType callback. Something like FunctionRef<void(Span<const bNodeSocket *> inputs, Span<const bNoeSocket *> outputs, MutableSpan<bNodeLink>)> NodeInternalLinksFn.
  2. For zones, reroute and group io nodes here should be a dummy versions for generate special links in simple pattern.
  3. In API there should be node type method to define custom links generation for custom nodes. Otherwise there should be used default i guess.. node sure how we can handle intenral links generation for custom sockets at all.
  4. For all other built-in common nodes there should be general implementation in a blender/nodes.

And at this step we start the actual links generation.

My initial attemp was in https://archive.blender.org/developer/D16684 Current thought about direction: 1. Move internal links generation to generic `bNodeType` callback. Something like `FunctionRef<void(Span<const bNodeSocket *> inputs, Span<const bNoeSocket *> outputs, MutableSpan<bNodeLink>)> NodeInternalLinksFn`. 2. For zones, reroute and group io nodes here should be a dummy versions for generate special links in simple pattern. 3. In API there should be node type method to define custom links generation for custom nodes. Otherwise there should be used default i guess.. node sure how we can handle intenral links generation for custom sockets at all. 4. For all other built-in common nodes there should be general implementation in a `blender/nodes`. And at this step we start the actual links generation.
Author
Member

My initial attemp was in https://archive.blender.org/developer/D16684
Current thought about direction:

  1. Move internal links generation to generic bNodeType callback. Something like FunctionRef<void(Span<const bNodeSocket *> inputs, Span<const bNoeSocket *> outputs, MutableSpan<bNodeLink>)> NodeInternalLinksFn.
  2. For zones, reroute and group io nodes here should be a dummy versions for generate special links in simple pattern.
  3. In API there should be node type method to define custom links generation for custom nodes. Otherwise there should be used default i guess.. node sure how we can handle intenral links generation for custom sockets at all.
  4. For all other built-in common nodes there should be general implementation in a blender/nodes.

And at this step we start the actual links generation.

D16684 refers to internal links. This patch is not concerned with that, it only affects the drag node onto link operator. See screenshots in main PR post.

> My initial attemp was in https://archive.blender.org/developer/D16684 > Current thought about direction: > 1. Move internal links generation to generic `bNodeType` callback. Something like `FunctionRef<void(Span<const bNodeSocket *> inputs, Span<const bNoeSocket *> outputs, MutableSpan<bNodeLink>)> NodeInternalLinksFn`. > 2. For zones, reroute and group io nodes here should be a dummy versions for generate special links in simple pattern. > 3. In API there should be node type method to define custom links generation for custom nodes. Otherwise there should be used default i guess.. node sure how we can handle intenral links generation for custom sockets at all. > 4. For all other built-in common nodes there should be general implementation in a `blender/nodes`. > > And at this step we start the actual links generation. D16684 refers to internal links. This patch is not concerned with that, it only affects the drag node onto link operator. See screenshots in main PR post.
All checks were successful
buildbot/vexp-code-patch-lint Build done.
buildbot/vexp-code-patch-windows-amd64 Build done.
buildbot/vexp-code-patch-coordinator Build done.
This pull request has changes conflicting with the target branch.
  • source/blender/editors/space_node/node_relationships.cc

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u node-drag-link:CharlieJolly-node-drag-link
git checkout CharlieJolly-node-drag-link
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
3 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#127868
No description provided.