diff --git a/source/blender/blenkernel/BKE_attribute.hh b/source/blender/blenkernel/BKE_attribute.hh index c0242f74e81..48e1d6f3e75 100644 --- a/source/blender/blenkernel/BKE_attribute.hh +++ b/source/blender/blenkernel/BKE_attribute.hh @@ -194,15 +194,21 @@ template struct AttributeReader { */ const ImplicitSharingInfo *sharing_info; - const VArray &operator*() const + const VArray &operator*() const & { return this->varray; } - VArray &operator*() + + VArray &operator*() & { return this->varray; } + VArray operator*() && + { + return std::move(this->varray); + } + operator bool() const { return this->varray; @@ -329,15 +335,21 @@ struct GAttributeReader { return this->varray; } - const GVArray &operator*() const + const GVArray &operator*() const & { return this->varray; } - GVArray &operator*() + + GVArray &operator*() & { return this->varray; } + GVArray operator*() && + { + return std::move(this->varray); + } + template AttributeReader typed() const { return {varray.typed(), domain, sharing_info}; diff --git a/source/blender/blenkernel/intern/geometry_component_curves.cc b/source/blender/blenkernel/intern/geometry_component_curves.cc index a59e14fe566..29017d111db 100644 --- a/source/blender/blenkernel/intern/geometry_component_curves.cc +++ b/source/blender/blenkernel/intern/geometry_component_curves.cc @@ -254,7 +254,7 @@ static VArray construct_curve_length_gvarray(const CurvesGeometry &curves { curves.ensure_evaluated_lengths(); - const VArray cyclic = curves.cyclic(); + VArray cyclic = curves.cyclic(); VArray lengths = VArray::ForFunc( curves.curves_num(), [&curves, cyclic = std::move(cyclic)](int64_t index) { return curves.evaluated_length_total_for_curve(index, cyclic[index]); diff --git a/source/blender/blenlib/BLI_generic_virtual_array.hh b/source/blender/blenlib/BLI_generic_virtual_array.hh index e9cf2092d1c..c47b6da1e6a 100644 --- a/source/blender/blenlib/BLI_generic_virtual_array.hh +++ b/source/blender/blenlib/BLI_generic_virtual_array.hh @@ -190,6 +190,7 @@ class GVArray : public GVArrayCommon { GVArray(varray_tag::single /*tag*/, const CPPType &type, int64_t size, const void *value); template GVArray(const VArray &varray); + template GVArray(VArray &&varray); template VArray typed() const; template static GVArray For(Args &&...args); @@ -870,7 +871,11 @@ template inline GVArray GVArray::For(Args &&.. return varray; } -template inline GVArray::GVArray(const VArray &varray) +template inline GVArray::GVArray(const VArray &varray) : GVArray(VArray(varray)) +{ +} + +template inline GVArray::GVArray(VArray &&varray) { if (!varray) { return; @@ -889,7 +894,7 @@ template inline GVArray::GVArray(const VArray &varray) if (varray.try_assign_GVArray(*this)) { return; } - *this = GVArray::For>(varray); + *this = GVArray::For>(std::move(varray)); } template inline VArray GVArray::typed() const diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh index 69f9018dec8..26a31a8be41 100644 --- a/source/blender/blenlib/BLI_virtual_array.hh +++ b/source/blender/blenlib/BLI_virtual_array.hh @@ -1035,7 +1035,9 @@ template class VArraySpan final : public Span { public: VArraySpan() = default; - VArraySpan(VArray varray) : Span(), varray_(std::move(varray)) + VArraySpan(const VArray &varray) : VArraySpan(VArray(varray)) {} + + VArraySpan(VArray &&varray) : Span(), varray_(std::move(varray)) { if (!varray_) { return; diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc index e459b9139b7..48f5ad1d663 100644 --- a/source/blender/draw/intern/draw_cache_impl_pointcloud.cc +++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.cc @@ -263,7 +263,7 @@ static void pointcloud_extract_position_and_radius(const PointCloud &pointcloud, MutableSpan vbo_data{ static_cast(GPU_vertbuf_get_data(cache.eval_cache.pos_rad)), pointcloud.totpoint}; if (radii) { - const VArraySpan radii_span(radii); + const VArraySpan radii_span(std::move(radii)); threading::parallel_for(vbo_data.index_range(), 4096, [&](IndexRange range) { for (const int i : range) { vbo_data[i].x = positions[i].x; diff --git a/source/blender/geometry/intern/realize_instances.cc b/source/blender/geometry/intern/realize_instances.cc index fd697ba8f71..1068b89330e 100644 --- a/source/blender/geometry/intern/realize_instances.cc +++ b/source/blender/geometry/intern/realize_instances.cc @@ -824,7 +824,7 @@ static void gather_attributes_for_propagation( const bke::GeometrySet &geometry_set, const Span component_types, const bke::GeometryComponent::Type dst_component_type, - const VArray instance_depth, + const VArray &instance_depth, const IndexMask selection, const bke::AnonymousAttributePropagationInfo &propagation_info, Map &r_attributes)