diff --git a/source/blender/blenkernel/BKE_attribute_storage.hh b/source/blender/blenkernel/BKE_attribute_storage.hh index b1c8df3bd2b..ee53dbef360 100644 --- a/source/blender/blenkernel/BKE_attribute_storage.hh +++ b/source/blender/blenkernel/BKE_attribute_storage.hh @@ -108,6 +108,9 @@ class Attribute { * \warning Does not yet support attributes stored as a single value (#AttrStorageType::Single). */ DataVariant &data_for_write(); + + /** Replace the attribute's data without first making the existing data mutable. */ + void assign_data(DataVariant &&data); }; class AttributeStorageRuntime { @@ -228,6 +231,11 @@ inline const Attribute::DataVariant &Attribute::data() const return data_; } +inline void Attribute::assign_data(DataVariant &&data) +{ + data_ = std::move(data); +} + } // namespace blender::bke inline blender::bke::AttributeStorage &AttributeStorage::wrap() diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index 5af023631bf..9adec5bad5c 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -232,7 +232,7 @@ static MutableSpan get_mutable_attribute(PointCloud &pointcloud, if (const auto *single_data = std::get_if(&attr->data())) { /* Convert single value storage to array storage. */ const GPointer g_value(CPPType::get(), single_data->value); - attr->data_for_write() = bke::Attribute::ArrayData::ForValue(g_value, pointcloud.totpoint); + attr->assign_data(bke::Attribute::ArrayData::ForValue(g_value, pointcloud.totpoint)); } auto &array_data = std::get(attr->data_for_write()); BLI_assert(array_data.size == pointcloud.totpoint); diff --git a/source/blender/geometry/intern/randomize.cc b/source/blender/geometry/intern/randomize.cc index 02b7a04104d..0a6989254f3 100644 --- a/source/blender/geometry/intern/randomize.cc +++ b/source/blender/geometry/intern/randomize.cc @@ -98,7 +98,7 @@ static void reorder_attribute_domain(bke::AttributeStorage &data, bke::attribute_math::gather(GSpan(type, data.data, data.size), new_by_old_map, GMutableSpan(type, new_data.data, new_data.size)); - attr.data_for_write() = std::move(new_data); + attr.assign_data(std::move(new_data)); } case bke::AttrStorageType::Single: { return;