diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-06-01 01:46:09 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-06-01 01:46:09 +0300 |
commit | 75162ab8c23937fce64e7b2674cc706a008ded96 (patch) | |
tree | e164662b22459b49aec8dcf4b597ea05ebfa80cd /source/blender/blenkernel/intern | |
parent | 511a08585d2934b38e7d3de447752686b5f0e15b (diff) |
Fix T97408: Temporary fix for attribute convert undo
Sculpt undo now detects if an attribute layer has
changed type/domain and unconverts it back. This
is a temporary workaround to a more fundamental
bug in the undo system.
Memfile undo assumes it can always rebuild the
application state from the prior undo step,
which isn't true with incremental undo systems.
The correct fix is to push an extra undo step prior
to running an operator if an incremental undo system
is active and the operator is using memfile undo.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/attribute.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c index 0cb0704ff80..870920bdf76 100644 --- a/source/blender/blenkernel/intern/attribute.c +++ b/source/blender/blenkernel/intern/attribute.c @@ -274,6 +274,35 @@ CustomDataLayer *BKE_id_attribute_find(const ID *id, return NULL; } +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]; @@ -641,6 +670,7 @@ CustomDataLayer *BKE_id_attributes_color_find(const ID *id, const char *name) if (layer == NULL) { layer = BKE_id_attribute_find(id, name, CD_PROP_BYTE_COLOR, ATTR_DOMAIN_CORNER); } + return layer; } |