diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-08-19 19:12:52 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-09-09 18:01:17 +0300 |
commit | 370d6e50252b979433f27959070315911cc340e5 (patch) | |
tree | f270972dd522a928e74b23334bb91a1cf174382f /source/blender/blenkernel/intern/attribute.c | |
parent | a1397a3cc69382a64ab97bb71e4769fc0add0791 (diff) |
Geometry: add Attributes panel for PointCloud and Hair
There is a list of attributes, along with operators to add and remove
attributes. For adding, there are a few standard attributes that can be
added quickly, as well as a popup to create a custom attribute.
Ref T76659
Differential Revision: https://developer.blender.org/D8636
Diffstat (limited to 'source/blender/blenkernel/intern/attribute.c')
-rw-r--r-- | source/blender/blenkernel/intern/attribute.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c index 8a67e4581f0..9ad73133f9e 100644 --- a/source/blender/blenkernel/intern/attribute.c +++ b/source/blender/blenkernel/intern/attribute.c @@ -101,6 +101,18 @@ static CustomData *attribute_customdata_find(ID *id, CustomDataLayer *layer) return NULL; } +bool BKE_id_attributes_supported(struct ID *id) +{ + DomainInfo info[ATTR_DOMAIN_NUM]; + get_domains(id, info); + for (AttributeDomain domain = 0; domain < ATTR_DOMAIN_NUM; domain++) { + if (info[domain].customdata) { + return true; + } + } + return false; +} + bool BKE_id_attribute_rename(ID *id, CustomDataLayer *layer, const char *new_name, @@ -139,7 +151,7 @@ CustomDataLayer *BKE_id_attribute_new( return (index == -1) ? NULL : &(customdata->layers[index]); } -void BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports) +bool BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports) { CustomData *customdata = attribute_customdata_find(id, layer); const int index = (customdata) ? @@ -148,16 +160,17 @@ void BKE_id_attribute_remove(ID *id, CustomDataLayer *layer, ReportList *reports if (index == -1) { BKE_report(reports, RPT_ERROR, "Attribute is not part of this geometry"); - return; + return false; } if (BKE_id_attribute_required(id, layer)) { BKE_report(reports, RPT_ERROR, "Attribute is required and can't be removed"); - return; + return false; } const int length = BKE_id_attribute_data_length(id, layer); CustomData_free_layer(customdata, layer->type, length, index); + return true; } int BKE_id_attributes_length(ID *id, const CustomDataMask mask) |