Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar Roman Cervantes <redvant>2021-02-20 01:03:14 +0300
committerHans Goudey <h.goudey@me.com>2021-02-20 01:03:14 +0300
commita961a2189cb38ffb368d6781aa57177bfefe0e36 (patch)
tree9fe23cadf50386676c42655e2b02e61144694384 /source/blender/makesrna/intern/rna_nodetree.c
parentee1c674775fd60352502f4d6062dbd4637865f9d (diff)
Geometry Nodes: Add string input node
This commit adds a simple string input node, intended for use in the attribute workflow to make using the same attribute name in multiple places easier. The node is function node similar to the existing vector input node. Ref T84971 Differential Revision: https://developer.blender.org/D10316
Diffstat (limited to 'source/blender/makesrna/intern/rna_nodetree.c')
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index b372ff4c273..65de8c479b8 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -4113,6 +4113,38 @@ void rna_ShaderNodePointDensity_density_minmax(bNode *self,
RE_point_density_minmax(depsgraph, pd, r_min, r_max);
}
+static void rna_NodeInputString_string_get(PointerRNA *ptr, char *value)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeInputString *storage = node->storage;
+
+ strcpy(value, (storage->string) ? storage->string : "");
+}
+
+static int rna_NodeInputString_string_length(PointerRNA *ptr)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeInputString *storage = node->storage;
+
+ return (storage->string) ? strlen(storage->string) : 0;
+}
+
+static void rna_NodeInputString_string_set(PointerRNA *ptr, const char *value)
+{
+ bNode *node = (bNode *)ptr->data;
+ NodeInputString *storage = node->storage;
+
+ if (storage->string) {
+ MEM_freeN(storage->string);
+ }
+
+ if (value && value[0]) {
+ storage->string = BLI_strdup(value);
+ }
+ else {
+ storage->string = NULL;
+ }
+}
#else
static const EnumPropertyItem prop_image_layer_items[] = {
@@ -4539,6 +4571,21 @@ static void def_fn_input_vector(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_fn_input_string(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeInputString", "storage");
+
+ prop = RNA_def_property(srna, "string", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop,
+ "rna_NodeInputString_string_get",
+ "rna_NodeInputString_string_length",
+ "rna_NodeInputString_string_set");
+ RNA_def_property_ui_text(prop, "String", "");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+}
+
/* -- Shader Nodes ---------------------------------------------------------- */
static void def_sh_output(StructRNA *srna)