[Bf-blender-cvs] [3d91a853b20] master: Cleanup: Nodes: Store node group idname in tree type

Hans Goudey noreply at git.blender.org
Thu Jul 28 23:34:31 CEST 2022


Commit: 3d91a853b209bc82296e40a65c2cb816e618ec70
Author: Hans Goudey
Date:   Thu Jul 28 16:34:17 2022 -0500
Branches: master
https://developer.blender.org/rB3d91a853b209bc82296e40a65c2cb816e618ec70

Cleanup: Nodes: Store node group idname in tree type

There was already a utility to retrieve the correct node group idname
from the context, `node_group_idname`, but often it's clearer to
use lower-level arguments, or the context isn't accessible.
Storing the group idname in the tree type makes it accessible
without rewriting it elsewhere.

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

M	source/blender/blenkernel/BKE_node.h
M	source/blender/editors/space_node/node_group.cc
M	source/blender/nodes/composite/node_composite_tree.cc
M	source/blender/nodes/geometry/node_geometry_tree.cc
M	source/blender/nodes/shader/node_shader_tree.cc
M	source/blender/nodes/texture/node_texture_tree.c

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

diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 90dbec7ec52..02e3cefe6a5 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -374,6 +374,9 @@ typedef struct bNodeTreeType {
   int type;        /* type identifier */
   char idname[64]; /* identifier name */
 
+  /* The ID name of group nodes for this type. */
+  char group_idname[64];
+
   char ui_name[64];
   char ui_description[256];
   int ui_icon;
diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc
index 160a379d3c6..d69d326c481 100644
--- a/source/blender/editors/space_node/node_group.cc
+++ b/source/blender/editors/space_node/node_group.cc
@@ -44,7 +44,12 @@
 #include "UI_resources.h"
 
 #include "NOD_common.h"
+#include "NOD_composite.h"
+#include "NOD_geometry.h"
+#include "NOD_shader.h"
 #include "NOD_socket.h"
+#include "NOD_texture.h"
+
 #include "node_intern.hh" /* own include */
 
 namespace blender::ed::space_node {
@@ -99,16 +104,16 @@ const char *node_group_idname(bContext *C)
   SpaceNode *snode = CTX_wm_space_node(C);
 
   if (ED_node_is_shader(snode)) {
-    return "ShaderNodeGroup";
+    return ntreeType_Shader->group_idname;
   }
   if (ED_node_is_compositor(snode)) {
-    return "CompositorNodeGroup";
+    return ntreeType_Composite->group_idname;
   }
   if (ED_node_is_texture(snode)) {
-    return "TextureNodeGroup";
+    return ntreeType_Texture->group_idname;
   }
   if (ED_node_is_geometry(snode)) {
-    return "GeometryNodeGroup";
+    return ntreeType_Geometry->group_idname;
   }
 
   return "";
diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc
index 32b5d98a556..6efe6f231f5 100644
--- a/source/blender/nodes/composite/node_composite_tree.cc
+++ b/source/blender/nodes/composite/node_composite_tree.cc
@@ -183,6 +183,7 @@ void register_node_tree_type_cmp()
 
   tt->type = NTREE_COMPOSIT;
   strcpy(tt->idname, "CompositorNodeTree");
+  strcpy(tt->group_idname, "CompositorNodeGroup");
   strcpy(tt->ui_name, N_("Compositor"));
   tt->ui_icon = ICON_NODE_COMPOSITING;
   strcpy(tt->ui_description, N_("Compositing nodes"));
diff --git a/source/blender/nodes/geometry/node_geometry_tree.cc b/source/blender/nodes/geometry/node_geometry_tree.cc
index 38e914b9a9f..e3998322741 100644
--- a/source/blender/nodes/geometry/node_geometry_tree.cc
+++ b/source/blender/nodes/geometry/node_geometry_tree.cc
@@ -109,6 +109,7 @@ void register_node_tree_type_geo()
       MEM_callocN(sizeof(bNodeTreeType), "geometry node tree type"));
   tt->type = NTREE_GEOMETRY;
   strcpy(tt->idname, "GeometryNodeTree");
+  strcpy(tt->group_idname, "GeometryNodeGroup");
   strcpy(tt->ui_name, N_("Geometry Node Editor"));
   tt->ui_icon = ICON_GEOMETRY_NODES;
   strcpy(tt->ui_description, N_("Geometry nodes"));
diff --git a/source/blender/nodes/shader/node_shader_tree.cc b/source/blender/nodes/shader/node_shader_tree.cc
index 43dbf5060bd..02ac54f4b2b 100644
--- a/source/blender/nodes/shader/node_shader_tree.cc
+++ b/source/blender/nodes/shader/node_shader_tree.cc
@@ -166,6 +166,7 @@ void register_node_tree_type_sh()
 
   tt->type = NTREE_SHADER;
   strcpy(tt->idname, "ShaderNodeTree");
+  strcpy(tt->group_idname, "ShaderNodeGroup");
   strcpy(tt->ui_name, N_("Shader Editor"));
   tt->ui_icon = ICON_NODE_MATERIAL;
   strcpy(tt->ui_description, N_("Shader nodes"));
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 03dc61af9a2..ac105b5bcb9 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -140,6 +140,7 @@ void register_node_tree_type_tex(void)
 
   tt->type = NTREE_TEXTURE;
   strcpy(tt->idname, "TextureNodeTree");
+  strcpy(tt->group_idname, "TextureNodeGroup");
   strcpy(tt->ui_name, N_("Texture Node Editor"));
   tt->ui_icon = ICON_NODE_TEXTURE; /* Defined in `drawnode.c`. */
   strcpy(tt->ui_description, N_("Texture nodes"));



More information about the Bf-blender-cvs mailing list