Nodes: Move data-block default values with link drag search #105972
No reviewers
Labels
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 project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105972
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "mod_moder/blender:move_value_by_link"
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?
When creating nodes by dragging a link, it can be convenient to
transfer values from input socket. For references value, like images,
this may be necessary. This patch starts adding such a system.
At this moment this only makes sense for one node (Image Input).
But this can be extended to work with other reference types, different
non-reference types and support auto-casting (if the float is transferred
to the Int Input node).
See task: #102854
Original patch: https://archive.blender.org/developer/D16735
Simon requested some changes after Hans accepted the patch.
So I guess it makes sense to be sure that I didn't do anything wrong with how to bypass each node instance.
afaict this is in a state that I already approved on phab and only needs potentially another round of code review
Geometry Node: Gather link searche: Ability to move values to the top using a new linkto Nodes: Link Drag Search: Move data-block default valuesNodes: Link Drag Search: Move data-block default valuesto Nodes: Move data-block default values with link drag searchThanks for updating this patch. I think the functionality works well, but I have some inline comments.
@ -2355,6 +2355,95 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
return node_dst;
}
void node_link_move_default_value_back(const bContext &C, bNodeTree &tree, const bNodeLink &link)
A clearer interface for this function might be:
That would allow moving in either direction, and clarify the source/destination from the link's from/to naming.
@ -2358,0 +2374,4 @@
}
if (&from_node == &to_node) {
/* Stop recursion. */
This doesn't seem necessary, there's no recursion in this function.
@ -2358,0 +2385,4 @@
switch (from_socket.type) {
case SOCK_IMAGE: {
Image **src_socket_value = &to_socket.default_value_typed<bNodeSocketValueImage>()->value;
It might be preferable to just use
ID *
rather thanImage *
here, since this logic could apply to all data-block socket types in the future, and no specific data fromImage
needs to be used.@ -2358,0 +2417,4 @@
for (bNode *group : other_tree->group_nodes()) {
if (reinterpret_cast<bNodeTree *>(group->id) == &tree) {
bNodeSocket *group_input_socket = reinterpret_cast<bNodeSocket *>(
BLI_findlink(&group->inputs, group_input_index));
Better to find the socket with the identifier in case we change group nodes to not store all the (hidden) sockets in the future.
@ -2355,6 +2355,95 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
return node_dst;
}
void node_link_move_default_value_back(const bContext &C, bNodeTree &tree, const bNodeLink &link)
Here the problem is that we must update the topology cache in advance in order to have access to the parent nodes of sockets from the function.
@ -2355,6 +2355,95 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
return node_dst;
}
void node_link_move_default_value_back(const bContext &C, bNodeTree &tree, const bNodeLink &link)
Yeah, I think that's okay, it can be documented in the function's doc-string or the function can just ensure the topology cache itself.
@ -2358,0 +2417,4 @@
for (bNode *group : other_tree->group_nodes()) {
if (reinterpret_cast<bNodeTree *>(group->id) == &tree) {
bNodeSocket *group_input_socket = reinterpret_cast<bNodeSocket *>(
BLI_findlink(&group->inputs, group_input_index));
There is some confusion here, it seems.
Hidden sockets that are inaccessible to built-in nodes will be deleted.
But if the user just doesn't want to see them, we shouldn't want to delete them, does it seem redundant that the node declaration store the hidden states for all sockets of all nodes?
So, for group nodes, created sockets will always exist..
@ -2358,0 +2417,4 @@
for (bNode *group : other_tree->group_nodes()) {
if (reinterpret_cast<bNodeTree *>(group->id) == &tree) {
bNodeSocket *group_input_socket = reinterpret_cast<bNodeSocket *>(
BLI_findlink(&group->inputs, group_input_index));
My point is, it's just less fragile to use identifiers rather than indices, and it gives us more flexibility in the future, for very little downside.
The code looks great. I'm just confused by the use of
group_identifier
andnode_find_tree_by_name
. Maybe I'm missing something though.You mean that it makes no sense to do such a unification for node tree, as with the socket name, getting one extra loop for search tree instance. Or a discrepancy in the naming of the node tree name?
Ah sorry, my inline comment disappeared somehow. What I mean is that this seems to retrieve the name from the tree, pass the name into the next function, and then just look up the tree by name again. That looks like equivalent to just passing the tree in the first place and skipping the name lookup.
@ -2358,0 +2360,4 @@
const Span<int> tree_types_to_lookup,
const FunctionRef<void(bNode &)> func)
{
BLI_assert(node_group != nullptr);
I think it's clearer to pass the node group as
const bNodeTree &group
and let this function handle theID *
comparison with something like&group.id
.@ -733,2 +733,4 @@
bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, int flag, bool use_unique);
/**
* Move socket default_value from TO_SOCKET to FROM_SOCKET or some other other place specified for
Sorry I should have found this this last time. I tried to update your PR directly but couldn't quite figure it out. This comment is a bit out of date. How about this?
@ -733,2 +733,4 @@
bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, int flag, bool use_unique);
/**
* Move socket default_value from TO_SOCKET to FROM_SOCKET or some other other place specified for
I was thinking about expanding with a description of the cases that may now be.
But given the plans to expand this functionality, is it correct to talk about it in a comment in header file?
@ -733,2 +733,4 @@
bNode *node_copy(bNodeTree *dst_tree, const bNode &src_node, int flag, bool use_unique);
/**
* Move socket default_value from TO_SOCKET to FROM_SOCKET or some other other place specified for
Maybe not, it's fine to keep it simple too. It's just nice to clarify that it doesn't just move to dst's default value
This is so needed for other socket types as well. It would really speed up workflows and remove an annoying papercut. Sverchok had this kind of function and it was always super handy