[Bf-blender-cvs] [f5dde382af8] master: Cleanup: use same function for updating internal links for all nodes

Jacques Lucke noreply at git.blender.org
Wed Nov 17 11:53:12 CET 2021


Commit: f5dde382af8078a2e5265e7d6710df7cb1b320a0
Author: Jacques Lucke
Date:   Wed Nov 17 11:52:44 2021 +0100
Branches: master
https://developer.blender.org/rBf5dde382af8078a2e5265e7d6710df7cb1b320a0

Cleanup: use same function for updating internal links for all nodes

Previously, node types had a callback that creates internal links. Pretty
much all nodes used the same callback though. The exceptions are the
reroute node (which probably shouldn't be mutable anyway) and some
input/output nodes that are not mutable.

Removing the callback helps with D13246, because it makes it easier
to reason about which internal links are created and when they change.
In the future, the internal links should be part of the node declaration.

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

M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.cc
M	source/blender/editors/space_node/node_edit.cc
M	source/blender/nodes/NOD_common.h
M	source/blender/nodes/composite/node_composite_util.cc
M	source/blender/nodes/composite/nodes/node_composite_common.cc
M	source/blender/nodes/composite/nodes/node_composite_composite.cc
M	source/blender/nodes/composite/nodes/node_composite_splitViewer.cc
M	source/blender/nodes/composite/nodes/node_composite_viewer.cc
M	source/blender/nodes/function/node_function_util.cc
M	source/blender/nodes/geometry/node_geometry_util.cc
M	source/blender/nodes/geometry/nodes/node_geo_common.cc
M	source/blender/nodes/intern/node_common.cc
M	source/blender/nodes/intern/node_util.c
M	source/blender/nodes/intern/node_util.h
M	source/blender/nodes/shader/node_shader_util.c
M	source/blender/nodes/shader/nodes/node_shader_common.c
M	source/blender/nodes/shader/nodes/node_shader_output_aov.c
M	source/blender/nodes/shader/nodes/node_shader_output_light.c
M	source/blender/nodes/shader/nodes/node_shader_output_linestyle.c
M	source/blender/nodes/shader/nodes/node_shader_output_material.c
M	source/blender/nodes/shader/nodes/node_shader_output_world.c
M	source/blender/nodes/texture/node_texture_util.c
M	source/blender/nodes/texture/nodes/node_texture_common.c
M	source/blender/nodes/texture/nodes/node_texture_output.c
M	source/blender/nodes/texture/nodes/node_texture_viewer.c

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

diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 8f7f224cf0f..bbeb01de0ff 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -318,8 +318,6 @@ typedef struct bNodeType {
 
   /* optional handling of link insertion */
   void (*insert_link)(struct bNodeTree *ntree, struct bNode *node, struct bNodeLink *link);
-  /* Update the internal links list, for muting and disconnect operators. */
-  void (*update_internal_links)(struct bNodeTree *, struct bNode *node);
 
   void (*free_self)(struct bNodeType *ntype);
 
@@ -344,6 +342,9 @@ typedef struct bNodeType {
   /* Declaration to be used when it is not dynamic. */
   NodeDeclarationHandle *fixed_declaration;
 
+  /** True when the node cannot be muted. */
+  bool no_muting;
+
   /* RNA integration */
   ExtensionRNA rna_ext;
 } bNodeType;
@@ -891,8 +892,6 @@ void node_type_exec(struct bNodeType *ntype,
                     NodeFreeExecFunction free_exec_fn,
                     NodeExecFunction exec_fn);
 void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn);
-void node_type_internal_links(struct bNodeType *ntype,
-                              void (*update_internal_links)(struct bNodeTree *, struct bNode *));
 
 /** \} */
 
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 850e3b8072a..e02ea3f7e37 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5237,9 +5237,8 @@ bool nodeUpdateID(bNodeTree *ntree, ID *id)
 void nodeUpdateInternalLinks(bNodeTree *ntree, bNode *node)
 {
   BLI_freelistN(&node->internal_links);
-
-  if (node->typeinfo && node->typeinfo->update_internal_links) {
-    node->typeinfo->update_internal_links(ntree, node);
+  if (!node->typeinfo->no_muting) {
+    node_internal_links_create(ntree, node);
   }
 }
 
@@ -5504,12 +5503,6 @@ void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
   ntype->gpu_fn = gpu_fn;
 }
 
-void node_type_internal_links(bNodeType *ntype,
-                              void (*update_internal_links)(bNodeTree *, bNode *))
-{
-  ntype->update_internal_links = update_internal_links;
-}
-
 /* callbacks for undefined types */
 
 static bool node_undefined_poll(bNodeType *UNUSED(ntype),
diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc
index f36ded22a39..30c9f7ea56b 100644
--- a/source/blender/editors/space_node/node_edit.cc
+++ b/source/blender/editors/space_node/node_edit.cc
@@ -1775,8 +1775,7 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op))
   ED_preview_kill_jobs(CTX_wm_manager(C), bmain);
 
   LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
-    /* Only allow muting of nodes having a mute func! */
-    if ((node->flag & SELECT) && node->typeinfo->update_internal_links) {
+    if ((node->flag & SELECT) && !node->typeinfo->no_muting) {
       node->flag ^= NODE_MUTED;
       snode_update(snode, node);
       do_tag_update |= (do_tag_update || node_connected_to_output(bmain, snode->edittree, node));
diff --git a/source/blender/nodes/NOD_common.h b/source/blender/nodes/NOD_common.h
index 50ed992dcb6..fa979bb4799 100644
--- a/source/blender/nodes/NOD_common.h
+++ b/source/blender/nodes/NOD_common.h
@@ -45,6 +45,8 @@ struct bNodeSocket *node_group_output_find_socket(struct bNode *node, const char
 void node_group_input_update(struct bNodeTree *ntree, struct bNode *node);
 void node_group_output_update(struct bNodeTree *ntree, struct bNode *node);
 
+void node_internal_links_create(struct bNodeTree *ntree, struct bNode *node);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/nodes/composite/node_composite_util.cc b/source/blender/nodes/composite/node_composite_util.cc
index 86aaec61bc3..21269b92e65 100644
--- a/source/blender/nodes/composite/node_composite_util.cc
+++ b/source/blender/nodes/composite/node_composite_util.cc
@@ -52,5 +52,4 @@ void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short ncla
   ntype->poll = cmp_node_poll_default;
   ntype->updatefunc = cmp_node_update_default;
   ntype->insert_link = node_insert_link_default;
-  ntype->update_internal_links = node_update_internal_links_default;
 }
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.cc b/source/blender/nodes/composite/nodes/node_composite_common.cc
index fecf6795ef7..6432a89ffa0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_common.cc
@@ -44,7 +44,6 @@ void register_node_type_cmp_group(void)
   ntype.poll = cmp_node_poll_default;
   ntype.poll_instance = node_group_poll_instance;
   ntype.insert_link = node_insert_link_default;
-  ntype.update_internal_links = node_update_internal_links_default;
   ntype.rna_ext.srna = RNA_struct_find("CompositorNodeGroup");
   BLI_assert(ntype.rna_ext.srna != nullptr);
   RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype);
@@ -66,7 +65,4 @@ void register_node_type_cmp_custom_group(bNodeType *ntype)
   if (ntype->insert_link == nullptr) {
     ntype->insert_link = node_insert_link_default;
   }
-  if (ntype->update_internal_links == nullptr) {
-    ntype->update_internal_links = node_update_internal_links_default;
-  }
 }
diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.cc b/source/blender/nodes/composite/nodes/node_composite_composite.cc
index 4247e81e9b2..a1a49133a3a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_composite.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_composite.cc
@@ -43,8 +43,7 @@ void register_node_type_cmp_composite(void)
   cmp_node_type_base(&ntype, CMP_NODE_COMPOSITE, "Composite", NODE_CLASS_OUTPUT, NODE_PREVIEW);
   ntype.declare = blender::nodes::cmp_node_composite_declare;
 
-  /* Do not allow muting for this node. */
-  node_type_internal_links(&ntype, nullptr);
+  ntype.no_muting = true;
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.cc b/source/blender/nodes/composite/nodes/node_composite_splitViewer.cc
index 68c5ecdf48e..c0403a041db 100644
--- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.cc
@@ -53,8 +53,7 @@ void register_node_type_cmp_splitviewer(void)
   node_type_init(&ntype, node_composit_init_splitviewer);
   node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage);
 
-  /* Do not allow muting for this node. */
-  node_type_internal_links(&ntype, nullptr);
+  ntype.no_muting = true;
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.cc b/source/blender/nodes/composite/nodes/node_composite_viewer.cc
index 969e2409898..90f9882099b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.cc
@@ -59,7 +59,7 @@ void register_node_type_cmp_viewer(void)
   node_type_init(&ntype, node_composit_init_viewer);
   node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage);
 
-  node_type_internal_links(&ntype, nullptr);
+  ntype.no_muting = true;
 
   nodeRegisterType(&ntype);
 }
diff --git a/source/blender/nodes/function/node_function_util.cc b/source/blender/nodes/function/node_function_util.cc
index 8ff8b416310..a1493d51a11 100644
--- a/source/blender/nodes/function/node_function_util.cc
+++ b/source/blender/nodes/function/node_function_util.cc
@@ -33,6 +33,5 @@ void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclas
 {
   node_type_base(ntype, type, name, nclass, flag);
   ntype->poll = fn_node_poll_default;
-  ntype->update_internal_links = node_update_internal_links_default;
   ntype->insert_link = node_insert_link_default;
 }
diff --git a/source/blender/nodes/geometry/node_geometry_util.cc b/source/blender/nodes/geometry/node_geometry_util.cc
index 8887be33f93..5c1d507041c 100644
--- a/source/blender/nodes/geometry/node_geometry_util.cc
+++ b/source/blender/nodes/geometry/node_geometry_util.cc
@@ -73,6 +73,5 @@ void geo_node_type_base(bNodeType *ntype, int type, const char *name, short ncla
 {
   node_type_base(ntype, type, name, nclass, flag);
   ntype->poll = geo_node_poll_default;
-  ntype->update_internal_links = node_update_internal_links_default;
   ntype->insert_link = node_insert_link_default;
 }
diff --git a/source/blender/nodes/geometry/nodes/node_geo_common.cc b/source/blender/nodes/geometry/nodes/node_geo_common.cc
index e2bb7e9f939..9ebbdd349de 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_common.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_common.cc
@@ -31,7 +31,6 @@ void register_node_type_geo_group(void)
   ntype.poll = geo_node_poll_default;
   ntype.poll_instance = node_group_poll_instance;
   ntype.insert_link = node_insert_link_default;
-  ntype.update_internal_links = node_update_internal_links_default;
   ntype.rna_ext.srna = RNA_struct_find("GeometryNodeGroup");
   BLI_assert(ntype.rna_ext.srna != nullptr);
   RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype);
@@ -53,7 +52,4 @@ void register_node_type_geo_custom_group(bNodeType *ntype)
   if (ntype->insert_link == nullptr) {
     ntype->insert_link = node_insert_link_default;
   }
-  if (ntype->update_internal_links == nullptr) {
-    ntype->update_internal_links = node_update_internal_links_default;
-  }
 }
diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc
index e5ec50858d9..b80cedc9352 100644
--- a/source/blender/nodes/intern/node_common.cc
+++ b/source/blender/nodes/intern/node_common.cc
@@ -251,26 +251,6 @@ void register_node_type_frame(void)
 /** \name Node Re-Route
  * \{ */
 
-/* simple, only a single input and output here */
-static void node_reroute_update_internal_links(bNodeTree *ntree, bNode *node)
-{
-  bNodeLink *link;
-
-  /* Security check! */
-  if (!ntree) {
-    return;
-  }
-
-  link = (bNodeLink *)MEM_callocN(sizeof(bNodeLink), "internal node link");
-  li

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list