[Bf-blender-cvs] [b33fd7e89ef] temp-attribute-processor: add Position Input/Output and Attribute Input node
Jacques Lucke
noreply at git.blender.org
Tue Jun 22 05:25:05 CEST 2021
Commit: b33fd7e89ef7e131587dc9febb87e1f29e0328ea
Author: Jacques Lucke
Date: Thu Jun 10 12:52:45 2021 +0200
Branches: temp-attribute-processor
https://developer.blender.org/rBb33fd7e89ef7e131587dc9febb87e1f29e0328ea
add Position Input/Output and Attribute Input node
===================================================================
M release/scripts/startup/nodeitems_builtins.py
M source/blender/blenkernel/BKE_node.h
M source/blender/blenkernel/intern/node.cc
M source/blender/makesdna/DNA_node_types.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/CMakeLists.txt
M source/blender/nodes/NOD_geometry.h
M source/blender/nodes/NOD_static_types.h
A source/blender/nodes/geometry/nodes/node_attr_attribute_input.cc
A source/blender/nodes/geometry/nodes/node_attr_position_input.cc
A source/blender/nodes/geometry/nodes/node_attr_position_output.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
===================================================================
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index ba8f3dfaca8..cbb915b8ae8 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -614,13 +614,15 @@ attribute_node_categories = [
AttributeNodeCategory("ATTR_INPUT", "Input", items=[
NodeItem("FunctionNodeRandomFloat"),
NodeItem("ShaderNodeValue"),
- NodeItem("ShaderNodeAttribute"),
NodeItem("FunctionNodeInputString"),
NodeItem("FunctionNodeInputVector"),
NodeItem("AttributeNodeIndex"),
+ NodeItem("AttributeNodeAttributeInput"),
+ NodeItem("AttributeNodePositionInput"),
]),
AttributeNodeCategory("ATTR_OUTPUT", "Output", items=[
NodeItem("AttributeNodeSetAttribute"),
+ NodeItem("AttributeNodePositionOutput"),
]),
AttributeNodeCategory("ATTR_UTILITIES", "Utilities", items=[
NodeItem("ShaderNodeMapRange"),
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 71f25120e69..784760ac03e 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1456,6 +1456,9 @@ int ntreeTexExecTree(struct bNodeTree *ntree,
#define ATTR_NODE_INDEX 1400
#define ATTR_NODE_SET_ATTRIBUTE 1401
+#define ATTR_NODE_POSITION_INPUT 1402
+#define ATTR_NODE_POSITION_OUTPUT 1403
+#define ATTR_NODE_ATTRIBUTE_INPUT 1404
/** \} */
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 338be7c3560..397029ac9ec 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5129,8 +5129,11 @@ static void registerGeometryNodes()
register_node_type_attr_group();
+ register_node_type_attr_attribute_input();
register_node_type_attr_index();
register_node_type_attr_set_attribute();
+ register_node_type_attr_position_input();
+ register_node_type_attr_position_output();
}
static void registerFunctionNodes()
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 59fada43bdd..6ffdad13a60 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1403,10 +1403,18 @@ typedef struct NodeGeometryAttributeProcessor {
typedef struct NodeAttributeSetAttribute {
char attribute_name[64];
+ /* eNodeSocketDatatype */
uint8_t type;
char _pad[7];
} NodeAttributeSetAttribute;
+typedef struct NodeAttributeAttributeInput {
+ char attribute_name[64];
+ /* eNodeSocketDatatype */
+ uint8_t type;
+ char _pad[7];
+} NodeAttributeAttributeInput;
+
/* script node mode */
#define NODE_SCRIPT_INTERNAL 0
#define NODE_SCRIPT_EXTERNAL 1
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 1186bcce3e2..e08885f9b18 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -10104,6 +10104,23 @@ static void def_attr_set_attribute(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
}
+static void def_attr_attribute_input(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeAttributeAttributeInput", "storage");
+
+ prop = RNA_def_property(srna, "attribute_name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Attribute Name", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, node_socket_data_type_items);
+ RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_AttributeNodeSetAttribute_type_itemf");
+ RNA_def_property_ui_text(prop, "Type", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update");
+}
+
/* -------------------------------------------------------------------------- */
static void rna_def_shader_node(BlenderRNA *brna)
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index e5151cbe6c5..db50e137bdf 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -139,8 +139,11 @@ set(SRC
function/nodes/node_fn_random_float.cc
function/node_function_util.cc
+ geometry/nodes/node_attr_attribute_input.cc
geometry/nodes/node_attr_group.cc
geometry/nodes/node_attr_index.cc
+ geometry/nodes/node_attr_position_input.cc
+ geometry/nodes/node_attr_position_output.cc
geometry/nodes/node_attr_set_attribute.cc
geometry/nodes/node_geo_align_rotation_to_vector.cc
geometry/nodes/node_geo_attribute_clamp.cc
diff --git a/source/blender/nodes/NOD_geometry.h b/source/blender/nodes/NOD_geometry.h
index 537de62f552..db15fa50f81 100644
--- a/source/blender/nodes/NOD_geometry.h
+++ b/source/blender/nodes/NOD_geometry.h
@@ -94,8 +94,11 @@ void register_node_tree_type_attr(void);
void register_node_type_attr_group(void);
void register_node_type_attribute_custom_group(bNodeType *ntype);
+void register_node_type_attr_attribute_input(void);
void register_node_type_attr_index(void);
void register_node_type_attr_set_attribute(void);
+void register_node_type_attr_position_input(void);
+void register_node_type_attr_position_output(void);
#ifdef __cplusplus
}
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 0ee861d6cb6..63d4d0b5566 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -328,6 +328,9 @@ DefNode(GeometryNode, GEO_NODE_VOLUME_TO_MESH, def_geo_volume_to_mesh, "VOLUME_T
DefNode(AttributeNode, ATTR_NODE_INDEX, 0, "INDEX", Index, "Index", "")
DefNode(AttributeNode, ATTR_NODE_SET_ATTRIBUTE, def_attr_set_attribute, "SET_ATTRIBUTE", SetAttribute, "Set Attribute", "")
+DefNode(AttributeNode, ATTR_NODE_POSITION_INPUT, 0, "POSITION_INPUT", PositionInput, "Position Input", "")
+DefNode(AttributeNode, ATTR_NODE_POSITION_OUTPUT, 0, "POSITION_OUTPUT", PositionOutput, "Position Output", "")
+DefNode(AttributeNode, ATTR_NODE_ATTRIBUTE_INPUT, def_attr_attribute_input, "ATTRIBUTE_INPUT", AttributeInput, "Attribute Input", "")
/* undefine macros */
#undef DefNode
diff --git a/source/blender/nodes/geometry/nodes/node_attr_attribute_input.cc b/source/blender/nodes/geometry/nodes/node_attr_attribute_input.cc
new file mode 100644
index 00000000000..8231dab68f6
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_attr_attribute_input.cc
@@ -0,0 +1,69 @@
+/*
+ * 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 "UI_interface.h"
+#include "UI_resources.h"
+
+#include "node_geometry_util.hh"
+
+static bNodeSocketTemplate attr_node_attribute_input_out[] = {
+ {SOCK_FLOAT, N_("Value")},
+ {SOCK_INT, N_("Value")},
+ {SOCK_BOOLEAN, N_("Value")},
+ {SOCK_VECTOR, N_("Value")},
+ {SOCK_RGBA, N_("Value")},
+ {-1, ""},
+};
+
+static void attr_node_attribute_input_layout(uiLayout *layout,
+ bContext *UNUSED(C),
+ PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "type", 0, "Type", ICON_NONE);
+ uiItemR(layout, ptr, "attribute_name", 0, "Name", ICON_NONE);
+}
+
+static void attr_node_attribute_input_init(bNodeTree *UNUSED(tree), bNode *node)
+{
+ NodeAttributeSetAttribute *data = (NodeAttributeSetAttribute *)MEM_callocN(
+ sizeof(NodeAttributeSetAttribute), __func__);
+ data->type = SOCK_FLOAT;
+ node->storage = data;
+}
+
+static void attr_node_attribute_input_update(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeAttributeSetAttribute *node_storage = (NodeAttributeSetAttribute *)node->storage;
+ LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
+ nodeSetSocketAvailability(socket, socket->type == (eNodeSocketDatatype)node_storage->type);
+ }
+}
+
+void register_node_type_attr_attribute_input()
+{
+ static bNodeType ntype;
+
+ attr_node_type_base(&ntype, ATTR_NODE_ATTRIBUTE_INPUT, "Attribute Input", NODE_CLASS_INPUT, 0);
+ node_type_socket_templates(&ntype, nullptr, attr_node_attribute_input_out);
+ node_type_storage(&ntype,
+ "NodeAttributeAttributeInput",
+ node_free_standard_storage,
+ node_copy_standard_storage);
+ node_type_init(&ntype, attr_node_attribute_input_init);
+ node_type_update(&ntype, attr_node_attribute_input_update);
+ ntype.draw_buttons = attr_node_attribute_input_layout;
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/geometry/nodes/node_attr_position_input.cc b/source/blender/nodes/geometry/nodes/node_attr_position_input.cc
new file mode 100644
index 00000000000..1f36ef72780
--- /dev/null
+++ b/source/blender/nodes/geometry/nodes/node_attr_position_input.cc
@@ -0,0 +1,34 @@
+/*
+ * 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 Fre
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list