From 91dd29fd45d190728f29cc2f6cf9cd5549392f61 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 21 Sep 2022 13:17:05 -0500 Subject: Attributes: Allow calling "finish" on empty accessors This removes some boilerplate when creating many optional attributes. --- source/blender/blenkernel/BKE_attribute.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_attribute.hh b/source/blender/blenkernel/BKE_attribute.hh index 97a8a91d0e4..7b13b8a2b09 100644 --- a/source/blender/blenkernel/BKE_attribute.hh +++ b/source/blender/blenkernel/BKE_attribute.hh @@ -264,7 +264,9 @@ template struct SpanAttributeWriter { */ void finish() { - this->span.save(); + if (this->span.varray()) { + this->span.save(); + } if (this->tag_modified_fn) { this->tag_modified_fn(); } @@ -339,7 +341,9 @@ struct GSpanAttributeWriter { void finish() { - this->span.save(); + if (this->span.varray()) { + this->span.save(); + } if (this->tag_modified_fn) { this->tag_modified_fn(); } -- cgit v1.2.3