From 35bb942ae3521cdb00a0a10ed3ec680741910389 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Sun, 19 Mar 2023 10:10:04 -0400 Subject: [PATCH] Cleanup: Use better check for UV map attribute Also check the domain in addition to the type, to avoid processing any associated layers unnecessarily. And remove an unnecessary comment too. --- source/blender/blenkernel/intern/attribute.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 64d54065b9e..9d406bb151c 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -438,8 +438,7 @@ bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports) id, color_name_from_index(id, color_clamp_index(id, default_index))); } - if (type == CD_PROP_FLOAT2) { - /* free associated UV map bool layers */ + if (type == CD_PROP_FLOAT2 && domain == ATTR_DOMAIN_CORNER) { char buffer[MAX_CUSTOMDATA_LAYER_NAME]; BM_data_layer_free_named( em->bm, data, BKE_uv_map_vert_select_name_get(name_copy.c_str(), buffer)); @@ -456,7 +455,6 @@ bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports) } std::optional attributes = get_attribute_accessor_for_write(*id); - if (!attributes) { return false; } @@ -487,8 +485,7 @@ bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports) BKE_id_attributes_default_color_set( id, color_name_from_index(id, color_clamp_index(id, default_index))); } - if (metadata->data_type == CD_PROP_FLOAT2) { - /* remove UV sub-attributes. */ + if (metadata->data_type == CD_PROP_FLOAT2 && metadata->domain == ATTR_DOMAIN_CORNER) { char buffer[MAX_CUSTOMDATA_LAYER_NAME]; attributes->remove(BKE_uv_map_vert_select_name_get(name_copy.c_str(), buffer)); attributes->remove(BKE_uv_map_edge_select_name_get(name_copy.c_str(), buffer));