diff options
author | Hans Goudey <h.goudey@me.com> | 2021-03-24 00:34:41 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-03-24 00:34:41 +0300 |
commit | 2495c0c53929d0480cfb6ae81502d79636a656b8 (patch) | |
tree | 5b4cc6e4852f62d877691bfe8f2001bebd349003 /source/blender/nodes | |
parent | 3ea1779365b577766a3d14a662f5cbd3bc81db53 (diff) |
Add new node tree type for nodes inside attribute processor group
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 3 | ||||
-rw-r--r-- | source/blender/nodes/NOD_function.h | 6 | ||||
-rw-r--r-- | source/blender/nodes/function/node_function_tree.cc | 68 | ||||
-rw-r--r-- | source/blender/nodes/function/node_function_util.cc | 2 | ||||
-rw-r--r-- | source/blender/nodes/function/nodes/node_function_common.cc | 45 |
5 files changed, 123 insertions, 1 deletions
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); +} |