1
1

Compare commits

...

3 Commits

Author SHA1 Message Date
1da326f237 Fix, add the ability to add a "processor" group
It is broken and doesn't do anything yet
2021-03-24 18:09:47 -04:00
4ea3d24930 Merge branch 'master' into temp-geometry-nodes-processor-prototype 2021-03-24 17:46:39 -04:00
2495c0c539 Add new node tree type for nodes inside attribute processor group 2021-03-23 17:34:41 -04:00
14 changed files with 159 additions and 3 deletions

View File

@@ -495,6 +495,7 @@ geometry_node_categories = [
NodeItem("GeometryNodeAttributeCombineXYZ"),
NodeItem("GeometryNodeAttributeSeparateXYZ"),
NodeItem("GeometryNodeAttributeRemove"),
NodeItem("FunctionNodeGroup"),
]),
GeometryNodeCategory("GEO_COLOR", "Color", items=[
NodeItem("ShaderNodeValToRGB"),

View File

@@ -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();
@@ -4967,6 +4969,7 @@ void BKE_node_system_init(void)
register_node_tree_type_sh();
register_node_tree_type_tex();
register_node_tree_type_geo();
register_node_tree_type_function();
register_node_type_frame();
register_node_type_reroute();

View File

@@ -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);

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 "";
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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",

View File

@@ -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

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -0,0 +1,46 @@
/*
* 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", "Attribute Processor", NODE_CLASS_ATTRIBUTE, 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);
}