From 6eea5f70e3b79e3c6683b7bc0e3e2998b67955d6 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 8 Jun 2022 10:42:21 +0200 Subject: Attributes: Use names instead of layers for some functions This mirrors the C++ attribute API better, separates the implementation of attributes from CustomData slightly, and makes functions simpler, clearer, and safer. Also fix an issue with removing an attribute caused by 97712b018df71c meant the first attribute with the given type was removed instead of the attribute with the given name. --- source/blender/makesrna/intern/rna_attribute.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index 2670e75d057..5e17f22ecf5 100644 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@ -163,13 +163,14 @@ static StructRNA *rna_Attribute_refine(PointerRNA *ptr) static void rna_Attribute_name_set(PointerRNA *ptr, const char *value) { - BKE_id_attribute_rename(ptr->owner_id, ptr->data, value, NULL); + const CustomDataLayer *layer = (const CustomDataLayer *)ptr->data; + BKE_id_attribute_rename(ptr->owner_id, layer->name, value, NULL); } static int rna_Attribute_name_editable(PointerRNA *ptr, const char **r_info) { CustomDataLayer *layer = ptr->data; - if (BKE_id_attribute_required(ptr->owner_id, layer)) { + if (BKE_id_attribute_required(ptr->owner_id, layer->name)) { *r_info = N_("Cannot modify name of required geometry attribute"); return false; } @@ -358,8 +359,8 @@ static PointerRNA rna_AttributeGroup_new( static void rna_AttributeGroup_remove(ID *id, ReportList *reports, PointerRNA *attribute_ptr) { - CustomDataLayer *layer = (CustomDataLayer *)attribute_ptr->data; - BKE_id_attribute_remove(id, layer, reports); + const CustomDataLayer *layer = (const CustomDataLayer *)attribute_ptr->data; + BKE_id_attribute_remove(id, layer->name, reports); RNA_POINTER_INVALIDATE(attribute_ptr); DEG_id_tag_update(id, ID_RECALC_GEOMETRY); -- cgit v1.2.3