From d633d9fd023bddab405bd276c49c8564da86d3aa Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 14 Apr 2023 12:42:28 -0400 Subject: [PATCH] Curves: Define "lookup int" function for RNA arrays The build seems to complain without this, though theoretically it isn't meant to be necessary. Though keeping them defined can potentially avoid quadratic lookups too. --- source/blender/makesrna/intern/rna_curves.c | 28 +++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_curves.c b/source/blender/makesrna/intern/rna_curves.c index 2ac738de914..bed608a5711 100644 --- a/source/blender/makesrna/intern/rna_curves.c +++ b/source/blender/makesrna/intern/rna_curves.c @@ -77,6 +77,18 @@ static void rna_Curves_curve_offset_data_begin(CollectionPropertyIterator *iter, NULL); } +static int rna_Curves_curve_offset_data_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + Curves *curves = rna_curves(ptr); + if (index < 0 || index >= curves->geometry.curve_num + 1) { + return false; + } + r_ptr->owner_id = &curves->id; + r_ptr->type = &RNA_IntAttributeValue; + r_ptr->data = &ED_curves_offsets_for_write(curves)[index]; + return true; +} + static float (*get_curves_positions(Curves *curves))[3] { return (float(*)[3])CustomData_get_layer_named_for_write( @@ -114,6 +126,18 @@ static int rna_Curves_curves_length(PointerRNA *ptr) return curves->geometry.curve_num; } +static int rna_Curves_curves_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + Curves *curves = rna_curves(ptr); + if (index < 0 || index >= curves->geometry.curve_num) { + return false; + } + r_ptr->owner_id = &curves->id; + r_ptr->type = &RNA_CurveSlice; + r_ptr->data = &ED_curves_offsets_for_write(curves)[index]; + return true; +} + static int rna_Curves_position_data_length(PointerRNA *ptr) { const Curves *curves = rna_curves(ptr); @@ -366,7 +390,7 @@ static void rna_def_curves(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_Curves_curves_length", - NULL, + "rna_Curves_curves_lookup_int", NULL, NULL); RNA_def_property_struct_type(prop, "CurveSlice"); @@ -408,7 +432,7 @@ static void rna_def_curves(BlenderRNA *brna) "rna_iterator_array_end", "rna_iterator_array_get", "rna_Curves_curve_offset_data_length", - NULL, + "rna_Curves_curve_offset_data_lookup_int", NULL, NULL); RNA_def_property_update(prop, 0, "rna_Curves_update_data");