diff options
Diffstat (limited to 'source/blender/blenkernel/intern/attribute.c')
-rw-r--r-- | source/blender/blenkernel/intern/attribute.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c index 49c255fc065..8a67e4581f0 100644 --- a/source/blender/blenkernel/intern/attribute.c +++ b/source/blender/blenkernel/intern/attribute.c @@ -39,6 +39,8 @@ #include "BKE_attribute.h" #include "BKE_customdata.h" +#include "BKE_hair.h" +#include "BKE_pointcloud.h" #include "BKE_report.h" #include "RNA_access.h" @@ -104,6 +106,11 @@ bool BKE_id_attribute_rename(ID *id, const char *new_name, ReportList *reports) { + if (BKE_id_attribute_required(id, layer)) { + BLI_assert(!"Required attribute name is not editable"); + return false; + } + CustomData *customdata = attribute_customdata_find(id, layer); if (customdata == NULL) { BKE_report(reports, RPT_ERROR, "Attribute is not part of this geometry"); @@ -144,6 +151,11 @@ void BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports return; } + if (BKE_id_attribute_required(id, layer)) { + BKE_report(reports, RPT_ERROR, "Attribute is required and can't be removed"); + return; + } + const int length = BKE_id_attribute_data_length(id, layer); CustomData_free_layer(customdata, layer->type, length, index); } @@ -197,6 +209,20 @@ int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer) return 0; } +bool BKE_id_attribute_required(ID *id, CustomDataLayer *layer) +{ + switch (GS(id->name)) { + case ID_PT: { + return BKE_pointcloud_customdata_required((PointCloud *)id, layer); + } + case ID_HA: { + return BKE_hair_customdata_required((Hair *)id, layer); + } + default: + return false; + } +} + CustomDataLayer *BKE_id_attributes_active_get(ID *id) { int active_index = *BKE_id_attributes_active_index_p(id); |