[Bf-blender-cvs] [165100d8ac5] temp-enum-socket: add node storage
Jacques Lucke
noreply at git.blender.org
Mon Nov 8 16:07:01 CET 2021
Commit: 165100d8ac57b34d5dd312510f50a747bcba7554
Author: Jacques Lucke
Date: Thu Nov 4 13:48:04 2021 +0100
Branches: temp-enum-socket
https://developer.blender.org/rB165100d8ac57b34d5dd312510f50a747bcba7554
add node storage
===================================================================
M source/blender/makesdna/DNA_node_types.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/NOD_static_types.h
M source/blender/nodes/function/nodes/node_fn_enum.cc
===================================================================
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index eaa5fb0f71c..9081f4ca33a 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1596,6 +1596,10 @@ typedef struct NodeGeometryViewer {
int8_t data_type;
} NodeGeometryViewer;
+typedef struct NodeFunctionEnum {
+ int some_value;
+} NodeFunctionEnum;
+
/* 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 2c20fa655e3..b5efde8e8f0 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -5066,6 +5066,18 @@ static void def_fn_input_string(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_fn_enum(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeFunctionEnum", "storage");
+
+ prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "some_value");
+ RNA_def_property_ui_text(prop, "Integer", "Input value used for unconnected socket");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
/* -- Shader Nodes ---------------------------------------------------------- */
static void def_sh_output(StructRNA *srna)
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index b157d77a57e..c67b65970cc 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -268,7 +268,7 @@ DefNode(FunctionNode, FN_NODE_LEGACY_RANDOM_FLOAT, 0, "LEGACY_RANDOM_FLOAT", Leg
DefNode(FunctionNode, FN_NODE_ALIGN_EULER_TO_VECTOR, def_fn_align_euler_to_vector, "ALIGN_EULER_TO_VECTOR", AlignEulerToVector, "Align Euler To Vector", "")
DefNode(FunctionNode, FN_NODE_BOOLEAN_MATH, def_boolean_math, "BOOLEAN_MATH", BooleanMath, "Boolean Math", "")
DefNode(FunctionNode, FN_NODE_COMPARE_FLOATS, def_float_compare, "COMPARE_FLOATS", CompareFloats, "Compare Floats", "")
-DefNode(FunctionNode, FN_NODE_ENUM, 0, "ENUM", Enum, "Enum", "")
+DefNode(FunctionNode, FN_NODE_ENUM, def_fn_enum, "ENUM", Enum, "Enum", "")
DefNode(FunctionNode, FN_NODE_FLOAT_TO_INT, def_float_to_int, "FLOAT_TO_INT", FloatToInt, "Float to Integer", "")
DefNode(FunctionNode, FN_NODE_INPUT_BOOL, def_fn_input_bool, "INPUT_BOOL", InputBool, "Boolean", "")
DefNode(FunctionNode, FN_NODE_INPUT_COLOR, def_fn_input_color, "INPUT_COLOR", InputColor, "Color", "")
diff --git a/source/blender/nodes/function/nodes/node_fn_enum.cc b/source/blender/nodes/function/nodes/node_fn_enum.cc
index d73fb8d1442..67d245e9b65 100644
--- a/source/blender/nodes/function/nodes/node_fn_enum.cc
+++ b/source/blender/nodes/function/nodes/node_fn_enum.cc
@@ -32,10 +32,15 @@ static void fn_node_enum_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Int>(N_("Integer"));
};
-static void fn_node_enum_layout(uiLayout *UNUSED(layout),
- bContext *UNUSED(C),
- PointerRNA *UNUSED(ptr))
+static void fn_node_enum_init(bNodeTree *UNUSED(tree), bNode *node)
{
+ NodeFunctionEnum *data = (NodeFunctionEnum *)MEM_callocN(sizeof(NodeFunctionEnum), __func__);
+ node->storage = data;
+}
+
+static void fn_node_enum_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "value", 0, "", ICON_NONE);
}
static const fn::MultiFunction *get_multi_function(bNode &UNUSED(bnode))
@@ -56,6 +61,9 @@ void register_node_type_fn_enum()
static bNodeType ntype;
fn_node_type_base(&ntype, FN_NODE_ENUM, "Enum", NODE_CLASS_SCRIPT, 0);
+ node_type_storage(
+ &ntype, "NodeFunctionEnum", node_free_standard_storage, node_copy_standard_storage);
+ node_type_init(&ntype, blender::nodes::fn_node_enum_init);
ntype.declare = blender::nodes::fn_node_enum_declare;
ntype.build_multi_function = blender::nodes::fn_node_enum_build_multi_function;
ntype.draw_buttons = blender::nodes::fn_node_enum_layout;
More information about the Bf-blender-cvs
mailing list