Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCsaba Boncsér <geochuder>2022-11-02 14:33:09 +0300
committerHans Goudey <h.goudey@me.com>2022-11-02 14:34:22 +0300
commit14e4c96b64f982dae26256be57c848ec134a72e9 (patch)
tree8921862fb5b8f047e31b6c348b6694faeba27ae5 /source/blender/blenkernel/intern/node.cc
parent5f7ca5462d31ff56f16016d5f9e6a5489b30a05e (diff)
Nodes: Reuse input sockets when creating new node groups
**Problem** Currently multiple input sockets are created when a new node group is made from selected nodes. Some of these are linked from the same source. It is not convenient to sort out and remove multiple input sockets that represent the same input. These inputs usually have meaningless names like 'value', 'x', etc. **Solution** Create common input sockets for each link starting from the same input. Move links inside the new group's node tree and reroute it to connect the common input socket to the original nodes. This is done by building up a mapping between the incoming link sources to the input interfaces created for them. The input interfaces are reused by the rest of the links having the same source. This patch also changes the way the input sockets get their names. Output socket names of the group nodes usually are specific and are given consciously. Use the output socket names from group nodes instead of the inputs where the links point to. Differential Revision: https://developer.blender.org/D15802
Diffstat (limited to 'source/blender/blenkernel/intern/node.cc')
-rw-r--r--source/blender/blenkernel/intern/node.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 8f8cd02e119..ad9d4e4fcca 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -3381,10 +3381,18 @@ struct bNodeSocket *ntreeAddSocketInterfaceFromSocket(bNodeTree *ntree,
bNode *from_node,
bNodeSocket *from_sock)
{
- bNodeSocket *iosock = ntreeAddSocketInterface(ntree,
- static_cast<eNodeSocketInOut>(from_sock->in_out),
- from_sock->idname,
- DATA_(from_sock->name));
+ return ntreeAddSocketInterfaceFromSocketWithName(
+ ntree, from_node, from_sock, from_sock->idname, from_sock->name);
+}
+
+struct bNodeSocket *ntreeAddSocketInterfaceFromSocketWithName(bNodeTree *ntree,
+ bNode *from_node,
+ bNodeSocket *from_sock,
+ const char *idname,
+ const char *name)
+{
+ bNodeSocket *iosock = ntreeAddSocketInterface(
+ ntree, static_cast<eNodeSocketInOut>(from_sock->in_out), idname, DATA_(name));
if (iosock) {
if (iosock->typeinfo->interface_from_socket) {
iosock->typeinfo->interface_from_socket(ntree, iosock, from_node, from_sock);