[Bf-blender-cvs] [2495c0c5392] temp-geometry-nodes-processor-prototype: Add new node tree type for nodes inside attribute processor group

Hans Goudey noreply at git.blender.org
Tue Mar 23 22:35:32 CET 2021


Commit: 2495c0c53929d0480cfb6ae81502d79636a656b8
Author: Hans Goudey
Date:   Tue Mar 23 17:34:41 2021 -0400
Branches: temp-geometry-nodes-processor-prototype
https://developer.blender.org/rB2495c0c53929d0480cfb6ae81502d79636a656b8

Add new node tree type for nodes inside attribute processor group

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

M	source/blender/blenkernel/intern/node.cc
M	source/blender/editors/include/ED_node.h
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_node/node_edit.c
M	source/blender/editors/space_node/node_group.c
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_function.h
A	source/blender/nodes/function/node_function_tree.cc
M	source/blender/nodes/function/node_function_util.cc
A	source/blender/nodes/function/nodes/node_function_common.cc

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

diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index d06e4030117..b1dea8f2814 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -4946,6 +4946,8 @@ static void registerGeometryNodes()
 
 static void registerFunctionNodes()
 {
+  register_node_type_function_group();
+
   register_node_type_fn_boolean_math();
   register_node_type_fn_float_compare();
   register_node_type_fn_input_string();
diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h
index 67a50b83bd6..0715036f169 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -101,6 +101,7 @@ bool ED_node_is_compositor(struct SpaceNode *snode);
 bool ED_node_is_shader(struct SpaceNode *snode);
 bool ED_node_is_texture(struct SpaceNode *snode);
 bool ED_node_is_geometry(struct SpaceNode *snode);
+bool ED_node_is_function(struct SpaceNode *snode);
 
 void ED_node_shader_default(const struct bContext *C, struct ID *id);
 void ED_node_composit_default(const struct bContext *C, struct Scene *scene);
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 1354c06305c..9d6c81e00b5 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -72,6 +72,7 @@
 #include "IMB_imbuf_types.h"
 
 #include "NOD_composite.h"
+#include "NOD_function.h"
 #include "NOD_geometry.h"
 #include "NOD_shader.h"
 #include "NOD_texture.h"
@@ -3286,6 +3287,7 @@ void ED_node_init_butfuncs(void)
   ntreeType_Shader->ui_icon = ICON_NODE_MATERIAL;
   ntreeType_Texture->ui_icon = ICON_NODE_TEXTURE;
   ntreeType_Geometry->ui_icon = ICON_NODETREE;
+  ntreeType_Function->ui_icon = ICON_NODETREE;
 }
 
 void ED_init_custom_node_type(bNodeType *ntype)
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index b72a6503749..f66486020fd 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -68,9 +68,11 @@
 #include "IMB_imbuf_types.h"
 
 #include "NOD_composite.h"
+#include "NOD_function.h"
 #include "NOD_geometry.h"
 #include "NOD_shader.h"
 #include "NOD_texture.h"
+
 #include "node_intern.h" /* own include */
 
 #define USE_ESC_COMPO
@@ -465,6 +467,11 @@ bool ED_node_is_geometry(struct SpaceNode *snode)
   return STREQ(snode->tree_idname, ntreeType_Geometry->idname);
 }
 
+bool ED_node_is_function(struct SpaceNode *snode)
+{
+  return STREQ(snode->tree_idname, ntreeType_Function->idname);
+}
+
 /* assumes nothing being done in ntree yet, sets the default in/out node */
 /* called from shading buttons or header */
 void ED_node_shader_default(const bContext *C, ID *id)
diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c
index e1de4bfc21e..fad5669f181 100644
--- a/source/blender/editors/space_node/node_group.c
+++ b/source/blender/editors/space_node/node_group.c
@@ -77,7 +77,8 @@ static bool node_group_operator_active_poll(bContext *C)
                  "ShaderNodeTree",
                  "CompositorNodeTree",
                  "TextureNodeTree",
-                 "GeometryNodeTree")) {
+                 "GeometryNodeTree",
+                 "FunctionNodeTree")) {
       return true;
     }
   }
@@ -94,7 +95,7 @@ static bool node_group_operator_editable(bContext *C)
      * with same keymap.
      */
     if (ED_node_is_shader(snode) || ED_node_is_compositor(snode) || ED_node_is_texture(snode) ||
-        ED_node_is_geometry(snode)) {
+        ED_node_is_geometry(snode) || ED_node_is_function(snode)) {
       return true;
     }
   }
@@ -123,6 +124,9 @@ const char *node_group_idname(bContext *C)
   if (ED_node_is_geometry(snode)) {
     return "GeometryNodeGroup";
   }
+  if (ED_node_is_function(snode)) {
+    return "FunctionNodeGroup";
+  }
 
   return "";
 }
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index f24d0e40d19..4aad8ca2742 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -512,6 +512,7 @@ typedef struct bNodeTree {
 #define NTREE_COMPOSIT 1
 #define NTREE_TEXTURE 2
 #define NTREE_GEOMETRY 3
+#define NTREE_FUNCTION 4
 
 /* ntree->init, flag */
 #define NTREE_TYPE_INIT 1
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index ba67cedfdbe..f298999cc20 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -281,6 +281,7 @@ extern StructRNA RNA_FreestyleModuleSettings;
 extern StructRNA RNA_FreestyleSettings;
 extern StructRNA RNA_Function;
 extern StructRNA RNA_FunctionNode;
+extern StructRNA RNA_FunctionNodeTree;
 extern StructRNA RNA_GPencilFrame;
 extern StructRNA RNA_GPencilInterpolateSettings;
 extern StructRNA RNA_GPencilLayer;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index d69a1e3dd06..091bd50dddf 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -11014,6 +11014,7 @@ static void rna_def_nodetree(BlenderRNA *brna)
       {NTREE_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture nodes"},
       {NTREE_COMPOSIT, "COMPOSITING", ICON_RENDERLAYERS, "Compositing", "Compositing nodes"},
       {NTREE_GEOMETRY, "GEOMETRY", ICON_NODETREE, "Geometry", "Geometry nodes"},
+      {NTREE_FUNCTION, "FUNCTION", ICON_NODETREE, "Function", "Attribute processor nodes"},
       {0, NULL, 0, NULL, NULL},
   };
 
@@ -11248,6 +11249,16 @@ static void rna_def_geometry_nodetree(BlenderRNA *brna)
   RNA_def_struct_ui_icon(srna, ICON_NODETREE);
 }
 
+static void rna_def_function_nodetree(BlenderRNA *brna)
+{
+  StructRNA *srna;
+
+  srna = RNA_def_struct(brna, "FunctionNodeTree", "NodeTree");
+  RNA_def_struct_ui_text(srna, "Function Node Tree", "");
+  RNA_def_struct_sdna(srna, "bNodeTree");
+  RNA_def_struct_ui_icon(srna, ICON_NODETREE);
+}
+
 static StructRNA *define_specific_node(BlenderRNA *brna,
                                        const char *struct_name,
                                        const char *base_name,
@@ -11345,6 +11356,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
   rna_def_shader_nodetree(brna);
   rna_def_texture_nodetree(brna);
   rna_def_geometry_nodetree(brna);
+  rna_def_function_nodetree(brna);
 
 #  define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
     { \
@@ -11368,6 +11380,7 @@ void RNA_def_nodetree(BlenderRNA *brna)
   define_specific_node(brna, "CompositorNodeGroup", "CompositorNode", "Group", "", def_group);
   define_specific_node(brna, "TextureNodeGroup", "TextureNode", "Group", "", def_group);
   define_specific_node(brna, "GeometryNodeGroup", "GeometryNode", "Group", "", def_group);
+  define_specific_node(brna, "FunctionNodeGroup", "FunctionNode", "Group", "", def_group);
   def_custom_group(brna,
                    "ShaderNodeCustomGroup",
                    "ShaderNode",
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 271f4e5c5e4..af7e6bdf737 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -136,8 +136,11 @@ set(SRC
   function/nodes/node_fn_input_string.cc
   function/nodes/node_fn_input_vector.cc
   function/nodes/node_fn_random_float.cc
+  function/nodes/node_function_common.cc
   function/node_function_util.cc
 
+  function/node_function_tree.cc
+
   geometry/nodes/node_geo_align_rotation_to_vector.cc
   geometry/nodes/node_geo_attribute_color_ramp.cc
   geometry/nodes/node_geo_attribute_combine_xyz.cc
diff --git a/source/blender/nodes/NOD_function.h b/source/blender/nodes/NOD_function.h
index b31b5326d66..a23b352e5dd 100644
--- a/source/blender/nodes/NOD_function.h
+++ b/source/blender/nodes/NOD_function.h
@@ -20,6 +20,12 @@
 extern "C" {
 #endif
 
+extern struct bNodeTreeType *ntreeType_Function;
+
+void register_node_tree_type_function(void);
+
+void register_node_type_function_group(void);
+
 void register_node_type_fn_boolean_math(void);
 void register_node_type_fn_float_compare(void);
 void register_node_type_fn_input_string(void);
diff --git a/source/blender/nodes/function/node_function_tree.cc b/source/blender/nodes/function/node_function_tree.cc
new file mode 100644
index 00000000000..2e8c8b3b545
--- /dev/null
+++ b/source/blender/nodes/function/node_function_tree.cc
@@ -0,0 +1,68 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <cstring>
+
+#include "MEM_guardedalloc.h"
+
+#include "NOD_function.h"
+
+#include "BKE_context.h"
+#include "BKE_node.h"
+#include "BKE_object.h"
+
+#include "BLT_translation.h"
+
+#include "DNA_modifier_types.h"
+#include "DNA_node_types.h"
+#include "DNA_space_types.h"
+
+#include "RNA_access.h"
+
+#include "node_common.h"
+
+bNodeTreeType *ntreeType_Function;
+
+static void function_node_tree_update(bNodeTree *ntree)
+{
+  /* Needed to give correct types to reroutes. */
+  ntree_update_reroute_nodes(ntree);
+}
+
+static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
+{
+  func(calldata, NODE_CLASS_INPUT, N_("Input"));
+  func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
+  func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
+  func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
+  func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
+}


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list