[Bf-blender-cvs] [626b7e45561] virtual-array-attributes: add materialize parameter
Jacques Lucke
noreply at git.blender.org
Tue Apr 13 09:01:51 CEST 2021
Commit: 626b7e45561d540d58a836eef8d90557e1ca0e28
Author: Jacques Lucke
Date: Tue Apr 13 08:26:43 2021 +0200
Branches: virtual-array-attributes
https://developer.blender.org/rB626b7e45561d540d58a836eef8d90557e1ca0e28
add materialize parameter
===================================================================
M source/blender/blenlib/BLI_virtual_array.hh
M source/blender/functions/FN_generic_virtual_array.hh
M source/blender/functions/intern/generic_virtual_array.cc
===================================================================
diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh
index 76f69851669..ce474f80fa9 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -422,15 +422,21 @@ template<typename T> class VMutableArray_Span final : public VMutableArray_For_M
bool show_not_applied_warning_ = true;
public:
- VMutableArray_Span(VMutableArray<T> &varray) : VMutableArray_For_MutableSpan<T>(varray.size())
+ VMutableArray_Span(VMutableArray<T> &varray, const bool materialize = true)
+ : VMutableArray_For_MutableSpan<T>(varray.size()), varray_(varray)
{
if (varray_.is_span()) {
this->data_ = varray_.get_span().data();
}
else {
- owned_data_.~Array();
- new (&owned_data_) Array<T>(varray_.size(), NoInitialization{});
- varray_.materialize_to_uninitialized(owned_data_);
+ if (materialize) {
+ owned_data_.~Array();
+ new (&owned_data_) Array<T>(varray_.size(), NoInitialization{});
+ varray_.materialize_to_uninitialized(owned_data_);
+ }
+ else {
+ owned_data_.reinitialize(varray_.size());
+ }
this->data_ = owned_data_.data();
}
}
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index 13d9bdc385d..991044617fe 100644
--- a/source/blender/functions/FN_generic_virtual_array.hh
+++ b/source/blender/functions/FN_generic_virtual_array.hh
@@ -544,7 +544,7 @@ class GVMutableArray_Span final : public GVMutableArray_For_GMutableSpan {
bool show_not_applied_warning_ = true;
public:
- GVMutableArray_Span(GVMutableArray &varray);
+ GVMutableArray_Span(GVMutableArray &varray, bool materialize = true);
~GVMutableArray_Span();
void apply();
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index 7fbec6dbf26..379863e3ca1 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -255,7 +255,7 @@ GVArray_Span::operator GSpan() const
* GVMutableArray_Span.
*/
-GVMutableArray_Span::GVMutableArray_Span(GVMutableArray &varray)
+GVMutableArray_Span::GVMutableArray_Span(GVMutableArray &varray, const bool materialize)
: GVMutableArray_For_GMutableSpan(varray.type(), varray.size()), varray_(varray)
{
if (varray_.is_span()) {
@@ -263,7 +263,12 @@ GVMutableArray_Span::GVMutableArray_Span(GVMutableArray &varray)
}
else {
owned_data_ = MEM_mallocN_aligned(type_->size() * size_, type_->alignment(), __func__);
- varray_.materialize_to_uninitialized(IndexRange(size_), owned_data_);
+ if (materialize) {
+ varray_.materialize_to_uninitialized(IndexRange(size_), owned_data_);
+ }
+ else {
+ type_->construct_default_n(owned_data_, size_);
+ }
data_ = owned_data_;
}
}
More information about the Bf-blender-cvs
mailing list