[Bf-blender-cvs] [06b5ceb0c4b] temp-nodes-group-declarations: Fixes to group creation

Hans Goudey noreply at git.blender.org
Thu Dec 29 22:31:30 CET 2022


Commit: 06b5ceb0c4b4caaca5b2e98ff2a8126d610ea8df
Author: Hans Goudey
Date:   Thu Dec 29 16:31:19 2022 -0500
Branches: temp-nodes-group-declarations
https://developer.blender.org/rB06b5ceb0c4b4caaca5b2e98ff2a8126d610ea8df

Fixes to group creation

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

M	source/blender/editors/space_node/node_group.cc
M	source/blender/nodes/geometry/nodes/node_geo_common.cc
M	source/blender/nodes/intern/node_declaration.cc
M	source/blender/nodes/intern/node_socket_declarations.cc

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

diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc
index 05e54cf6bff..043bd8f7c76 100644
--- a/source/blender/editors/space_node/node_group.cc
+++ b/source/blender/editors/space_node/node_group.cc
@@ -936,7 +936,6 @@ static void node_group_make_insert_selected(const bContext &C,
   /* Update input and output node first, since the group node declaration can depend on them. */
   nodes::update_node_declaration_and_sockets(group, *input_node);
   nodes::update_node_declaration_and_sockets(group, *output_node);
-  nodes::update_node_declaration_and_sockets(ntree, *gnode);
 
   /* move nodes in the group to the center */
   for (bNode *node : nodes_to_move) {
@@ -957,6 +956,7 @@ static void node_group_make_insert_selected(const bContext &C,
     nodeRemLink(&ntree, link);
   }
 
+  /* Handle links to the new group inputs. */
   for (const auto item : input_links.items()) {
     const char *interface_identifier = item.value.interface_socket->identifier;
     bNodeSocket *input_socket = node_group_input_find_socket(input_node, interface_identifier);
@@ -970,23 +970,17 @@ static void node_group_make_insert_selected(const bContext &C,
       link->fromnode = input_node;
       link->fromsock = input_socket;
     }
-
-    /* Add a new link outside of the group. */
-    bNodeSocket *group_node_socket = node_group_find_input_socket(gnode, interface_identifier);
-    nodeAddLink(&ntree, item.value.from_node, item.key, gnode, group_node_socket);
   }
 
+  /* Handle links to new group outputs. */
   for (const OutputLinkInfo &info : output_links) {
     /* Create a new link inside of the group. */
     const char *io_identifier = info.interface_socket->identifier;
     bNodeSocket *output_sock = node_group_output_find_socket(output_node, io_identifier);
     nodeAddLink(&group, info.link->fromnode, info.link->fromsock, output_node, output_sock);
-
-    /* Reconnect the link to the group node instead of the node now inside the group. */
-    info.link->fromnode = gnode;
-    info.link->fromsock = node_group_find_output_socket(gnode, io_identifier);
   }
 
+  /* Handle new links inside the group. */
   for (const NewInternalLinkInfo &info : new_internal_links) {
     const char *io_identifier = info.interface_socket->identifier;
     if (info.socket->in_out == SOCK_IN) {
@@ -998,6 +992,26 @@ static void node_group_make_insert_selected(const bContext &C,
       nodeAddLink(&group, info.node, info.socket, output_node, output_socket);
     }
   }
+
+  ED_node_tree_propagate_change(&C, bmain, &group);
+
+  nodes::update_node_declaration_and_sockets(ntree, *gnode);
+
+  /* Add new links to inputs outside of the group. */
+  for (const auto item : input_links.items()) {
+    const char *interface_identifier = item.value.interface_socket->identifier;
+    bNodeSocket *group_node_socket = node_group_find_input_socket(gnode, interface_identifier);
+    nodeAddLink(&ntree, item.value.from_node, item.key, gnode, group_node_socket);
+  }
+
+  /* Add new links to outputs outside the group. */
+  for (const OutputLinkInfo &info : output_links) {
+    /* Reconnect the link to the group node instead of the node now inside the group. */
+    info.link->fromnode = gnode;
+    info.link->fromsock = node_group_find_output_socket(gnode, info.interface_socket->identifier);
+  }
+
+  ED_node_tree_propagate_change(&C, bmain, &ntree);
 }
 
 static bNode *node_group_make_from_nodes(const bContext &C,
@@ -1052,8 +1066,6 @@ static int node_group_make_exec(bContext *C, wmOperator *op)
     }
   }
 
-  ED_node_tree_propagate_change(C, bmain, nullptr);
-
   WM_event_add_notifier(C, NC_NODE | NA_ADDED, nullptr);
 
   /* We broke relations in node tree, need to rebuild them in the graphs. */
@@ -1106,7 +1118,6 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
   SpaceNode *snode = CTX_wm_space_node(C);
   bNodeTree *ntree = snode->edittree;
   const char *node_idname = node_group_idname(C);
-  Main *bmain = CTX_data_main(C);
 
   ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C));
 
@@ -1138,7 +1149,6 @@ static int node_group_insert_exec(bContext *C, wmOperator *op)
 
   nodeSetActive(ntree, gnode);
   ED_node_tree_push(snode, ngroup, gnode);
-  ED_node_tree_propagate_change(C, bmain, nullptr);
 
   return OPERATOR_FINISHED;
 }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_common.cc b/source/blender/nodes/geometry/nodes/node_geo_common.cc
index b9912c20543..6830d819b34 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_common.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_common.cc
@@ -28,11 +28,11 @@ static void node_declare(const bNodeTree &node_tree,
   }
 
   const FieldInferencingInterface &field_interface = *group->runtime->field_inferencing_interface;
-  for (const int i : r_declaration.inputs_.index_range()) {
-    r_declaration.inputs_[i]->input_field_type_ = field_interface.inputs[i];
+  for (const int i : r_declaration.inputs.index_range()) {
+    r_declaration.inputs[i]->input_field_type = field_interface.inputs[i];
   }
-  for (const int i : r_declaration.outputs_.index_range()) {
-    r_declaration.outputs_[i]->output_field_dependency_ = field_interface.outputs[i];
+  for (const int i : r_declaration.outputs.index_range()) {
+    r_declaration.outputs[i]->output_field_dependency = field_interface.outputs[i];
   }
 }
 
diff --git a/source/blender/nodes/intern/node_declaration.cc b/source/blender/nodes/intern/node_declaration.cc
index 646fe1e11ae..2c59440ea97 100644
--- a/source/blender/nodes/intern/node_declaration.cc
+++ b/source/blender/nodes/intern/node_declaration.cc
@@ -18,8 +18,8 @@ void build_node_declaration_dynamic(const bNodeTree &node_tree,
                                     const bNode &node,
                                     NodeDeclaration &r_declaration)
 {
-  r_declaration.inputs_.clear();
-  r_declaration.outputs_.clear();
+  r_declaration.inputs.clear();
+  r_declaration.outputs.clear();
   node.typeinfo->declare_dynamic(node_tree, node, r_declaration);
 }
 
diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc
index 8195064522b..2cdfc9a6928 100644
--- a/source/blender/nodes/intern/node_socket_declarations.cc
+++ b/source/blender/nodes/intern/node_socket_declarations.cc
@@ -548,14 +548,18 @@ bool Shader::can_connect(const bNodeSocket &socket) const
 
 bNodeSocket &Extend::build(bNodeTree &ntree, bNode &node) const
 {
-  bNodeSocket &socket = *nodeAddSocket(
-      &ntree, &node, in_out_, "NodeSocketVirtual", identifier_.c_str(), name_.c_str());
+  bNodeSocket &socket = *nodeAddSocket(&ntree,
+                                       &node,
+                                       this->in_out,
+                                       "NodeSocketVirtual",
+                                       this->identifier.c_str(),
+                                       this->name.c_str());
   return socket;
 }
 
 bool Extend::matches(const bNodeSocket &socket) const
 {
-  if (socket.identifier != identifier_) {
+  if (socket.identifier != this->identifier) {
     return false;
   }
   return true;
@@ -582,7 +586,7 @@ bNodeSocket &Extend::update_or_build(bNodeTree & /*ntree*/,
 bNodeSocket &Custom::build(bNodeTree &ntree, bNode &node) const
 {
   bNodeSocket &socket = *nodeAddSocket(
-      &ntree, &node, in_out_, idname_, identifier_.c_str(), name_.c_str());
+      &ntree, &node, this->in_out, idname_, this->identifier.c_str(), this->name.c_str());
   return socket;
 }



More information about the Bf-blender-cvs mailing list