[Bf-blender-cvs] [6c4b72b1357] master: Fix T101746: Node copy and paste changes multi-input socket order

Hans Goudey noreply at git.blender.org
Fri Oct 14 21:20:11 CEST 2022


Commit: 6c4b72b135749a3a9c405f410c6eec85fa0c1cc1
Author: Hans Goudey
Date:   Fri Oct 14 14:07:55 2022 -0500
Branches: master
https://developer.blender.org/rB6c4b72b135749a3a9c405f410c6eec85fa0c1cc1

Fix T101746: Node copy and paste changes multi-input socket order

The multi-input indices have to be copied, and updated after
pasting in case all original connected nodes weren't copied.

===================================================================

M	source/blender/editors/space_node/node_edit.cc
M	source/blender/editors/space_node/node_intern.hh
M	source/blender/editors/space_node/node_relationships.cc

===================================================================

diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index b01be5ff234..48b3d711bdf 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -2299,6 +2299,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator * /*op*/)
       newlink->tosock = socket_map.lookup(link->tosock);
       newlink->fromnode = node_map.lookup(link->fromnode);
       newlink->fromsock = socket_map.lookup(link->fromsock);
+      newlink->multi_input_socket_index = link->multi_input_socket_index;
 
       BKE_node_clipboard_add_link(newlink);
     }
@@ -2420,11 +2421,19 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
   }
 
   LISTBASE_FOREACH (bNodeLink *, link, clipboard_links_lb) {
-    nodeAddLink(ntree,
-                node_map.lookup(link->fromnode),
-                socket_map.lookup(link->fromsock),
-                node_map.lookup(link->tonode),
-                socket_map.lookup(link->tosock));
+    bNodeLink *new_link = nodeAddLink(ntree,
+                                      node_map.lookup(link->fromnode),
+                                      socket_map.lookup(link->fromsock),
+                                      node_map.lookup(link->tonode),
+                                      socket_map.lookup(link->tosock));
+    new_link->multi_input_socket_index = link->multi_input_socket_index;
+  }
+
+  ntree->ensure_topology_cache();
+
+  for (bNode *new_node : node_map.values()) {
+    /* Update multi input socket indices in case all connected nodes weren't copied. */
+    update_multi_input_indices_for_removed_links(*new_node);
   }
 
   Main *bmain = CTX_data_main(C);
diff --git a/source/blender/editors/space_node/node_intern.hh b/source/blender/editors/space_node/node_intern.hh
index 50c03489027..1c3026628a6 100644
--- a/source/blender/editors/space_node/node_intern.hh
+++ b/source/blender/editors/space_node/node_intern.hh
@@ -270,6 +270,8 @@ void NODE_OT_group_edit(wmOperatorType *ot);
 
 /* node_relationships.cc */
 
+void update_multi_input_indices_for_removed_links(bNode &node);
+
 void NODE_OT_link(wmOperatorType *ot);
 void NODE_OT_link_make(wmOperatorType *ot);
 void NODE_OT_links_cut(wmOperatorType *ot);
diff --git a/source/blender/editors/space_node/node_relationships.cc b/source/blender/editors/space_node/node_relationships.cc
index f53eaf0f2bd..b12afcb1faa 100644
--- a/source/blender/editors/space_node/node_relationships.cc
+++ b/source/blender/editors/space_node/node_relationships.cc
@@ -75,8 +75,6 @@ static void clear_picking_highlight(ListBase *links)
   }
 }
 
-void update_multi_input_indices_for_removed_links(bNode &node);
-
 /* -------------------------------------------------------------------- */
 /** \name Add Node
  * \{ */



More information about the Bf-blender-cvs mailing list