diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-06-01 02:35:22 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-06-01 02:35:22 +0300 |
commit | b38a59881be863bff079b4600a08d6b3a8b4b59a (patch) | |
tree | 713fb7596630d92631b459fe5072b64e3eec1644 /source/blender/blenkernel/intern | |
parent | 79cee340a8af413822e752057b71bf0c91e6e40c (diff) | |
parent | 6cee4049143abf692af6ffb78c109fb0760fe67d (diff) |
Merge branch 'blender-v3.2-release'
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/attribute.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index cfddae7721b..7ca38573d25 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -284,6 +284,35 @@ CustomDataLayer *BKE_id_attribute_find(const ID *id, return nullptr; } +CustomDataLayer *BKE_id_attribute_search(const ID *id, + const char *name, + const CustomDataMask type_mask, + const AttributeDomainMask domain_mask) +{ + DomainInfo info[ATTR_DOMAIN_NUM]; + get_domains(id, info); + + for (AttributeDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; domain++) { + if (!(domain_mask & ATTR_DOMAIN_AS_MASK(domain))) { + continue; + } + + CustomData *customdata = info[domain].customdata; + if (customdata == NULL) { + return NULL; + } + + for (int i = 0; i < customdata->totlayer; i++) { + CustomDataLayer *layer = &customdata->layers[i]; + if ((CD_TYPE_AS_MASK(layer->type) & type_mask) && STREQ(layer->name, name)) { + return layer; + } + } + } + + return NULL; +} + int BKE_id_attributes_length(const ID *id, AttributeDomainMask domain_mask, CustomDataMask mask) { DomainInfo info[ATTR_DOMAIN_NUM]; @@ -651,6 +680,7 @@ CustomDataLayer *BKE_id_attributes_color_find(const ID *id, const char *name) if (layer == nullptr) { layer = BKE_id_attribute_find(id, name, CD_PROP_BYTE_COLOR, ATTR_DOMAIN_CORNER); } + return layer; } |