[Bf-blender-cvs] [7dfd49922ad] temp-geometry-nodes-mix-attributes: add custom storage to node
Jacques Lucke
noreply at git.blender.org
Wed Dec 9 15:03:30 CET 2020
Commit: 7dfd49922ad29e0ceadb2382012ce9738f3f6d5d
Author: Jacques Lucke
Date: Wed Dec 9 12:39:52 2020 +0100
Branches: temp-geometry-nodes-mix-attributes
https://developer.blender.org/rB7dfd49922ad29e0ceadb2382012ce9738f3f6d5d
add custom storage to node
===================================================================
M source/blender/makesdna/DNA_node_types.h
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
===================================================================
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 29c83d2d4ed..2aa0bb961b0 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -1059,6 +1059,16 @@ typedef struct NodeDenoise {
char _pad[7];
} NodeDenoise;
+typedef struct NodeAttributeMix {
+ /* e.g. MA_RAMP_BLEND. */
+ uint8_t blend_type;
+
+ /* GeometryNodeAttributeInputMode */
+ uint8_t input_type_factor;
+ uint8_t input_type_a;
+ uint8_t input_type_b;
+} NodeAttributeMix;
+
/* script node mode */
#define NODE_SCRIPT_INTERNAL 0
#define NODE_SCRIPT_EXTERNAL 1
@@ -1464,6 +1474,13 @@ typedef enum GeometryNodeUseAttributeFlag {
GEO_NODE_USE_ATTRIBUTE_B = (1 << 1),
} GeometryNodeUseAttributeFlag;
+typedef enum GeometryNodeAttributeInputMode {
+ GEO_NODE_ATTRIBUTE_INPUT__ATTRIBUTE = 0,
+ GEO_NODE_ATTRIBUTE_INPUT__CONSTANT_FLOAT = 1,
+ GEO_NODE_ATTRIBUTE_INPUT__CONSTANT_VECTOR = 2,
+ GEO_NODE_ATTRIBUTE_INPUT__CONSTANT_COLOR = 3,
+} GeometryNodeAttributeInputMode;
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 383594364ca..c435c40e7a6 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -8372,8 +8372,9 @@ static void def_geo_attribute_mix(StructRNA *srna)
{
PropertyRNA *prop;
+ RNA_def_struct_sdna_from(srna, "NodeAttributeMix", "storage");
+
prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
- RNA_def_property_enum_sdna(prop, NULL, "custom1");
RNA_def_property_enum_items(prop, rna_enum_ramp_blend_items);
RNA_def_property_enum_default(prop, MA_RAMP_BLEND);
RNA_def_property_ui_text(prop, "Blending Mode", "");
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
index 69ad214dfa7..955ada7d83d 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_mix.cc
@@ -162,6 +162,17 @@ static void geo_node_attribute_mix_exec(GeoNodeExecParams params)
params.set_output("Geometry", geometry_set);
}
+static void geo_node_attribute_mix_init(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeAttributeMix *data = (NodeAttributeMix *)MEM_callocN(sizeof(NodeAttributeMix),
+ "attribute mix node");
+ data->blend_type = MA_RAMP_BLEND;
+ data->input_type_factor = GEO_NODE_ATTRIBUTE_INPUT__CONSTANT_FLOAT;
+ data->input_type_a = GEO_NODE_ATTRIBUTE_INPUT__ATTRIBUTE;
+ data->input_type_b = GEO_NODE_ATTRIBUTE_INPUT__ATTRIBUTE;
+ node->storage = data;
+}
+
} // namespace blender::nodes
void register_node_type_geo_attribute_mix()
@@ -170,6 +181,9 @@ void register_node_type_geo_attribute_mix()
geo_node_type_base(&ntype, GEO_NODE_ATTRIBUTE_MIX, "Attribute Mix", NODE_CLASS_ATTRIBUTE, 0);
node_type_socket_templates(&ntype, geo_node_attribute_mix_in, geo_node_mix_attribute_out);
+ node_type_init(&ntype, blender::nodes::geo_node_attribute_mix_init);
+ node_type_storage(
+ &ntype, "NodeAttributeMix", node_free_standard_storage, node_copy_standard_storage);
ntype.geometry_node_execute = blender::nodes::geo_node_attribute_mix_exec;
nodeRegisterType(&ntype);
}
More information about the Bf-blender-cvs
mailing list