[Bf-blender-cvs] [ec77f2d11d4] temp-attribute-processor: support creating attribute processor
Jacques Lucke
noreply at git.blender.org
Thu May 27 12:51:41 CEST 2021
Commit: ec77f2d11d48ed5428178651cf75a32d2c9db8e3
Author: Jacques Lucke
Date: Mon May 24 16:36:00 2021 +0200
Branches: temp-attribute-processor
https://developer.blender.org/rBec77f2d11d48ed5428178651cf75a32d2c9db8e3
support creating attribute processor
===================================================================
M release/scripts/startup/bl_operators/node.py
M source/blender/editors/space_node/drawnode.c
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
===================================================================
diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index 6150789ea10..221ec86230e 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -364,6 +364,31 @@ class NODE_OT_active_preview_toggle(Operator):
return spreadsheets
+class NODE_OT_new_attribute_processor_group(Operator):
+ bl_idname= "node.new_attribute_processor_group"
+ bl_label = "New Attribute Processor Group"
+ bl_options = {'REGISTER', 'UNDO'}
+
+ node_name: StringProperty()
+
+ @classmethod
+ def poll(cls, context):
+ space = context.space_data
+ if space is None:
+ return False
+ if space.type != 'NODE_EDITOR':
+ return False
+ return space.edit_tree is not None
+
+ def execute(self, context):
+ node = context.space_data.edit_tree.nodes[self.node_name]
+ if node.bl_idname != "GeometryNodeAttributeProcessor":
+ return {'CANCELLED'}
+ new_group = bpy.data.node_groups.new("Attribute Group", "AttributeNodeTree")
+ node.node_tree = new_group
+ return {'FINISHED'}
+
+
classes = (
NodeSetting,
@@ -373,4 +398,5 @@ classes = (
NODE_OT_collapse_hide_unused_toggle,
NODE_OT_tree_path_parent,
NODE_OT_active_preview_toggle,
+ NODE_OT_new_attribute_processor_group,
)
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index d74523ea73f..fbcfb46bb49 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3306,7 +3306,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_Attribute->ui_icon = ICON_NONE;
+ ntreeType_Attribute->ui_icon = ICON_SPREADSHEET;
}
void ED_init_custom_node_type(bNodeType *ntype)
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 4ac27f2c6ce..9596919eab9 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4462,6 +4462,13 @@ bool rna_NodeSocketMaterial_default_value_poll(PointerRNA *UNUSED(ptr), PointerR
return ma->gp_style == NULL;
}
+static bool rna_GeometrNodeAttributeProcessor_node_tree_poll(PointerRNA *ptr,
+ const PointerRNA value)
+{
+ bNodeTree *ngroup = value.data;
+ return STREQ(ngroup->idname, "AttributeNodeTree");
+}
+
#else
static const EnumPropertyItem prop_image_layer_items[] = {
@@ -9879,6 +9886,8 @@ static void def_geo_attribute_processor(StructRNA *srna)
prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "id");
RNA_def_property_struct_type(prop, "NodeTree");
+ RNA_def_property_pointer_funcs(
+ prop, NULL, NULL, NULL, "rna_GeometrNodeAttributeProcessor_node_tree_poll");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Node Tree", "");
@@ -11528,7 +11537,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_ATTRIBUTE, "ATTRIBUTE", ICON_NONE, "Attribute", "Attribute Nodes"},
+ {NTREE_ATTRIBUTE, "ATTRIBUTE", ICON_SPREADSHEET, "Attribute", "Attribute Nodes"},
{0, NULL, 0, NULL, NULL},
};
@@ -11780,7 +11789,7 @@ static void rna_def_attribute_nodetree(BlenderRNA *brna)
"Attribute Node Tree",
"Node tree consisting of linked nodes used for attribute processing");
RNA_def_struct_sdna(srna, "bNodeTree");
- RNA_def_struct_ui_icon(srna, ICON_NONE);
+ RNA_def_struct_ui_icon(srna, ICON_SPREADSHEET);
}
static StructRNA *define_specific_node(BlenderRNA *brna,
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
index 4757b021be5..16bfebfa81a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
@@ -30,8 +30,11 @@
static void geo_node_attribute_processor_layout(uiLayout *layout, bContext *C, PointerRNA *ptr)
{
+ bNode *node = (bNode *)ptr->data;
+ uiLayout *row = uiLayoutRow(layout, true);
uiTemplateIDBrowse(
- layout, C, ptr, "node_tree", nullptr, nullptr, nullptr, UI_TEMPLATE_ID_FILTER_ALL, nullptr);
+ row, C, ptr, "node_tree", nullptr, nullptr, nullptr, UI_TEMPLATE_ID_FILTER_ALL, nullptr);
+ uiItemStringO(row, "", ICON_PLUS, "node.new_attribute_processor_group", "node_name", node->name);
}
static void geo_node_attribute_processor_init(bNodeTree *UNUSED(ntree), bNode *node)
More information about the Bf-blender-cvs
mailing list