Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/node.cc2
-rw-r--r--source/blender/editors/include/ED_node.h1
-rw-r--r--source/blender/editors/space_node/drawnode.c2
-rw-r--r--source/blender/editors/space_node/node_edit.c7
-rw-r--r--source/blender/editors/space_node/node_group.c8
-rw-r--r--source/blender/makesdna/DNA_node_types.h1
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c13
-rw-r--r--source/blender/nodes/CMakeLists.txt3
-rw-r--r--source/blender/nodes/NOD_function.h6
-rw-r--r--source/blender/nodes/function/node_function_tree.cc68
-rw-r--r--source/blender/nodes/function/node_function_util.cc2
-rw-r--r--source/blender/nodes/function/nodes/node_function_common.cc45
13 files changed, 156 insertions, 3 deletions
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 6864d34885a..f5b2eb01269 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"));
+}
+
+void register_node_tree_type_function(void)
+{
+ bNodeTreeType *tt = ntreeType_Function = static_cast<bNodeTreeType *>(
+ MEM_callocN(sizeof(bNodeTreeType), "function node tree type"));
+ tt->type = NTREE_FUNCTION;
+ strcpy(tt->idname, "FunctionNodeTree");
+ strcpy(tt->ui_name, N_("Function Node Editor"));
+ tt->ui_icon = 0; /* defined in drawnode.c */
+ strcpy(tt->ui_description, N_("Function nodes"));
+ tt->rna_ext.srna = &RNA_FunctionNodeTree;
+ tt->update = function_node_tree_update;
+ tt->foreach_nodeclass = foreach_nodeclass;
+
+ ntreeTypeAdd(tt);
+}
diff --git a/source/blender/nodes/function/node_function_util.cc b/source/blender/nodes/function/node_function_util.cc
index 827572d1069..f10a2d2ad20 100644
--- a/source/blender/nodes/function/node_function_util.cc
+++ b/source/blender/nodes/function/node_function_util.cc
@@ -20,7 +20,7 @@
bool fn_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
{
/* Function nodes are only supported in simulation node trees so far. */
- return STREQ(ntree->idname, "GeometryNodeTree");
+ return STR_ELEM(ntree->idname, "GeometryNodeTree", "FunctionNodeTree");
}
void fn_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
diff --git a/source/blender/nodes/function/nodes/node_function_common.cc b/source/blender/nodes/function/nodes/node_function_common.cc
new file mode 100644
index 00000000000..b9734f9e36c
--- /dev/null
+++ b/source/blender/nodes/function/nodes/node_function_common.cc
@@ -0,0 +1,45 @@
+/*
+ * 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 "BKE_node.h"
+
+#include "NOD_function.h"
+
+#include "NOD_common.h"
+#include "node_common.h"
+#include "node_function_util.hh"
+
+void register_node_type_function_group(void)
+{
+ static bNodeType ntype;
+
+ node_type_base_custom(&ntype, "FunctionNodeGroup", "Group", NODE_CLASS_GROUP, 0);
+ ntype.type = NODE_GROUP;
+ ntype.poll = fn_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("FunctionNodeGroup");
+ BLI_assert(ntype.rna_ext.srna != nullptr);
+ RNA_struct_blender_type_set(ntype.rna_ext.srna, &ntype);
+
+ node_type_socket_templates(&ntype, nullptr, nullptr);
+ node_type_size(&ntype, 140, 60, 400);
+ node_type_label(&ntype, node_group_label);
+ node_type_group_update(&ntype, node_group_update);
+
+ nodeRegisterType(&ntype);
+}