From e9ff079131ee08b794b2b52815a5fc520ab06dbc Mon Sep 17 00:00:00 2001 From: Thomas Barlow Date: Mon, 22 Jan 2024 17:39:51 +0100 Subject: [PATCH] RNA: Use sdna for ByteIntAttributeValue.value This enables raw access to the property, which enables raw array access to the property through ByteIntAttribute.data, speeding up Python API access through foreach_get/foreach_set (bpy_rna.cc#foreach_getset). Pull Request: https://projects.blender.org/blender/blender/pulls/117409 --- .../blender/makesrna/intern/rna_attribute.cc | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/source/blender/makesrna/intern/rna_attribute.cc b/source/blender/makesrna/intern/rna_attribute.cc index aca5c5ae761..bf6afefa838 100644 --- a/source/blender/makesrna/intern/rna_attribute.cc +++ b/source/blender/makesrna/intern/rna_attribute.cc @@ -389,28 +389,6 @@ static void rna_FloatColorAttributeValue_color_srgb_set(PointerRNA *ptr, const f srgb_to_linearrgb_v4(col->color, values); } -/* Int8 Attribute. */ - -static int rna_ByteIntAttributeValue_get(PointerRNA *ptr) -{ - int8_t *value = (int8_t *)ptr->data; - return int(*value); -} - -static void rna_ByteIntAttributeValue_set(PointerRNA *ptr, const int new_value) -{ - int8_t *value = (int8_t *)ptr->data; - if (new_value > INT8_MAX) { - *value = INT8_MAX; - } - else if (new_value < INT8_MIN) { - *value = INT8_MIN; - } - else { - *value = int8_t(new_value); - } -} - /* Attribute Group */ static PointerRNA rna_AttributeGroup_new( @@ -1044,8 +1022,7 @@ static void rna_def_attribute_int8(BlenderRNA *brna) RNA_def_struct_ui_text( srna, "8-bit Integer Attribute Value", "8-bit value in geometry attribute"); prop = RNA_def_property(srna, "value", PROP_INT, PROP_NONE); - RNA_def_property_int_funcs( - prop, "rna_ByteIntAttributeValue_get", "rna_ByteIntAttributeValue_set", nullptr); + RNA_def_property_int_sdna(prop, nullptr, "i"); } static void rna_def_attribute_int2(BlenderRNA *brna)