From e37f3388b1563591153fc82259cf549f7942dcf0 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 12 Sep 2022 10:36:56 -0500 Subject: Attributes: Add function to retrieve span without adding attribute Previously, the only versions of attribute access that gave a span would also add the attribute when it doesn't exist, which isn't always wanted. --- source/blender/blenkernel/intern/attribute_access.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 6ca3a286a5e..69f3e5bb389 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -875,6 +875,16 @@ GAttributeWriter MutableAttributeAccessor::lookup_for_write(const AttributeIDRef return attribute; } +GSpanAttributeWriter MutableAttributeAccessor::lookup_for_write_span( + const AttributeIDRef &attribute_id) +{ + GAttributeWriter attribute = this->lookup_for_write(attribute_id); + if (attribute) { + return GSpanAttributeWriter{std::move(attribute), true}; + } + return {}; +} + GAttributeWriter MutableAttributeAccessor::lookup_or_add_for_write( const AttributeIDRef &attribute_id, const eAttrDomain domain, -- cgit v1.2.3