[Bf-blender-cvs] [24474a60b6b] geometry-nodes-attribute-nodes: Geometry Nodes: Use std::string for string sockets
Hans Goudey
noreply at git.blender.org
Sun Nov 1 05:57:27 CET 2020
Commit: 24474a60b6b9d0186cf81b93c0ff9116ddcc7b40
Author: Hans Goudey
Date: Sat Oct 31 23:57:14 2020 -0500
Branches: geometry-nodes-attribute-nodes
https://developer.blender.org/rB24474a60b6b9d0186cf81b93c0ff9116ddcc7b40
Geometry Nodes: Use std::string for string sockets
===================================================================
M release/scripts/startup/nodeitems_builtins.py
M source/blender/editors/space_node/drawnode.c
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/nodes/NOD_static_types.h
M source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
M source/blender/nodes/geometry/nodes/node_geo_attribute_random.cc
===================================================================
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index f3fbca47977..c3e1f837c3a 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -493,7 +493,7 @@ geometry_node_categories = [
NodeItem("GeometryNodeSubdivisionSurface"),
]),
GeometryNodeCategory("GEO_ATTRIBUTES", "Attributes", items=[
- NodeItem("GeometryNodeCreateAttribute"),
+ # NodeItem("GeometryNodeCreateAttribute"),
NodeItem("GeometryNodeRandomAttribute"),
NodeItem("GeometryNodeAttributeMath"),
]),
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 18e1d173fdd..0537c692393 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3155,6 +3155,14 @@ static void node_geometry_buts_attribute_math(uiLayout *layout,
uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
}
+static void node_geometry_buts_attribute_random(uiLayout *layout,
+ bContext *UNUSED(C),
+ PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "data_type", DEFAULT_FLAGS, "", ICON_NONE);
+ uiItemR(layout, ptr, "domain", DEFAULT_FLAGS, "", ICON_NONE);
+}
+
static void node_geometry_buts_boolean_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiItemR(layout, ptr, "operation", DEFAULT_FLAGS, "", ICON_NONE);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 662ec0d2c41..ffab5b88f5b 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -8173,7 +8173,7 @@ static void def_geo_boolean(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
-static void def_geo_attribute_create(StructRNA *srna)
+static void def_geo_attribute_common(StructRNA *srna)
{
PropertyRNA *prop;
@@ -8192,6 +8192,11 @@ static void def_geo_attribute_create(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_geo_attribute_create(StructRNA *srna)
+{
+ def_geo_attribute_common(srna);
+}
+
static void def_geo_attribute_math(StructRNA *srna)
{
PropertyRNA *prop;
@@ -8204,6 +8209,11 @@ static void def_geo_attribute_math(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
}
+static void def_geo_attribute_random(StructRNA *srna)
+{
+ def_geo_attribute_common(srna);
+}
+
/* -------------------------------------------------------------------------- */
static void rna_def_shader_node(BlenderRNA *brna)
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 0097eafd4b5..f0582ed4b0f 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -273,7 +273,7 @@ DefNode(GeometryNode, GEO_NODE_SUBDIVISION_SURFACE, 0, "SUBDIVISION_SURFACE", Su
DefNode(GeometryNode, GEO_NODE_BOOLEAN, def_geo_boolean, "BOOLEAN", Boolean, "Boolean", "")
DefNode(GeometryNode, GEO_NODE_POINT_DISTRIBUTE, 0, "POINT_DISTRIBUTE", PointDistribute, "Point Distribute", "")
DefNode(GeometryNode, GEO_NODE_POINT_INSTANCE, 0, "POINT_INSTANCE", PointInstance, "Point Instance", "")
-DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_RANDOM, 0, "ATTRIBUTE_RANDOM", RandomAttribute, "Random Attribute", "")
+DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_RANDOM, def_geo_attribute_random, "ATTRIBUTE_RANDOM", RandomAttribute, "Random Attribute", "")
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_MATH, def_geo_attribute_math, "ATTRIBUTE_MATH", AttributeMath, "Attribute Math", "")
DefNode(GeometryNode, GEO_NODE_ATTRIBUTE_CREATE, def_geo_attribute_create, "ATTRIBUTE_CREATE", CreateAttribute, "Create Attribute", "")
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
index 5ccce185a31..28400c90b1a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_math.cc
@@ -47,9 +47,9 @@ static void geo_attribute_math_exec(bNode *UNUSED(node),
make_geometry_mutable(geometry);
- // Mesh *mesh = geometry->get_mesh_for_write();
- // const char *attribute_name_a = inputs.extract<const char *>("Attribute A");
- // const char *attribute_name_b = inputs.extract<const char *>("Attribute B");
+ Mesh *mesh = geometry->get_mesh_for_write();
+ std::string attribute_name_a = inputs.extract<std::string>("Attribute A");
+ std::string attribute_name_b = inputs.extract<std::string>("Attribute B");
outputs.set("Geometry", std::move(geometry));
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_random.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_random.cc
index 7a691d35d30..de2f91a73b0 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_random.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_random.cc
@@ -41,9 +41,7 @@ static void geo_attribute_random_init(bNodeTree *UNUSED(tree), bNode *node)
}
namespace blender::nodes {
-static void geo_attribute_random_exec(bNode *UNUSED(node),
- GeoNodeInputs inputs,
- GeoNodeOutputs outputs)
+static void geo_attribute_random_exec(bNode *node, GeoNodeInputs inputs, GeoNodeOutputs outputs)
{
GeometryPtr geometry = inputs.extract<GeometryPtr>("Geometry");
@@ -54,9 +52,16 @@ static void geo_attribute_random_exec(bNode *UNUSED(node),
make_geometry_mutable(geometry);
- // RandomNumberGenerator rng(0);
- // Mesh *mesh = geometry->get_mesh_for_write();
- // const char *attribute_name = inputs.extract<const char *>("Attribute");
+ RandomNumberGenerator rng(0);
+ Mesh *mesh = geometry->get_mesh_for_write();
+ std::string attribute_name = inputs.extract<std::string>("Attribute");
+
+ CustomDataType data_type = static_cast<CustomDataType>(node->custom1);
+ AttributeDomain domain = static_cast<AttributeDomain>(node->custom2);
+
+ ReportList report_list_dummy;
+ CustomDataLayer *custom_data = BKE_id_attribute_new(
+ reinterpret_cast<ID *>(mesh), attribute_name.c_str(), data_type, domain, &report_list_dummy);
outputs.set("Geometry", std::move(geometry));
}
More information about the Bf-blender-cvs
mailing list