diff options
author | Hans Goudey <h.goudey@me.com> | 2021-10-20 17:57:54 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-10-20 17:57:54 +0300 |
commit | 990b912fd76cd9a2bf0278e7a5bc4a2029e024d2 (patch) | |
tree | 2d99061834d5ffdda05c3ad3f5235d11833eaf4b /source/blender/blenkernel/BKE_attribute_access.hh | |
parent | 494c3fb1bdb425059b26abd21d7c9230eda68438 (diff) |
Cleanup: Add check whether to remove an anonymous atttribute
Add a higher level check that can be used instead of checking whether
the attribute ID is anonymous and checking whether it has any strong
references.
Diffstat (limited to 'source/blender/blenkernel/BKE_attribute_access.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_attribute_access.hh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh index ff2aebc7d10..4a1c29badb4 100644 --- a/source/blender/blenkernel/BKE_attribute_access.hh +++ b/source/blender/blenkernel/BKE_attribute_access.hh @@ -55,6 +55,7 @@ class AttributeIDRef { bool is_anonymous() const; StringRef name() const; const AnonymousAttributeID &anonymous_id() const; + bool should_be_kept() const; friend bool operator==(const AttributeIDRef &a, const AttributeIDRef &b); friend std::ostream &operator<<(std::ostream &stream, const AttributeIDRef &attribute_id); @@ -438,6 +439,16 @@ inline const AnonymousAttributeID &AttributeIDRef::anonymous_id() const return *anonymous_id_; } +/** + * \return True if the attribute should not be removed automatically as an optimization during + * processing or copying. Anonymous attributes can be removed when they no longer have any + * references. + */ +inline bool AttributeIDRef::should_be_kept() const +{ + return this->is_named() || BKE_anonymous_attribute_id_has_strong_references(anonymous_id_); +} + /** \} */ /* -------------------------------------------------------------------- */ |