From dda02a448a38a5f5f4b0df1738bec3b158ce739f Mon Sep 17 00:00:00 2001 From: Victor-Louis De Gusseme Date: Thu, 25 Mar 2021 23:29:33 -0400 Subject: Geometry Nodes: Add Attribute Map Range Node This commit adds a node with a "Map Range" operation for attributes just like the non-attribute version of the node. However, unlike the regular version of the node, it also supports operations on vectors. Differential Revision: https://developer.blender.org/D10344 --- source/blender/makesrna/intern/rna_nodetree.c | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source/blender/makesrna/intern') diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index d69a1e3dd06..7f2120c02e9 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2065,6 +2065,17 @@ static void rna_GeometryNodeAttributeVectorMath_operation_update(Main *bmain, rna_Node_socket_update(bmain, scene, ptr); } +static bool attribute_map_range_type_supported(const EnumPropertyItem *item) +{ + return ELEM(item->value, CD_PROP_FLOAT, CD_PROP_FLOAT3); +} +static const EnumPropertyItem *rna_GeometryNodeAttributeMapRange_type_itemf( + bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +{ + *r_free = true; + return itemf_function_check(rna_enum_attribute_type_items, attribute_map_range_type_supported); +} + static StructRNA *rna_ShaderNode_register(Main *bmain, ReportList *reports, void *data, @@ -8915,6 +8926,26 @@ static void def_geo_attribute_vector_math(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); } +static void def_geo_attribute_map_range(StructRNA *srna) +{ + PropertyRNA *prop; + + RNA_def_struct_sdna_from(srna, "NodeAttributeMapRange", "storage"); + + prop = RNA_def_property(srna, "data_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "data_type"); + RNA_def_property_enum_items(prop, rna_enum_attribute_type_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_GeometryNodeAttributeMapRange_type_itemf"); + RNA_def_property_ui_text(prop, "Data Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_socket_update"); + + prop = RNA_def_property(srna, "interpolation_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "interpolation_type"); + RNA_def_property_enum_items(prop, rna_enum_node_map_range_items); + RNA_def_property_ui_text(prop, "Interpolation Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); +} + static void def_geo_point_instance(StructRNA *srna) { static const EnumPropertyItem instance_type_items[] = { -- cgit v1.2.3