[Bf-blender-cvs] [ddb7cb7e4ab] master: Geometry Nodes: Simplify using OutputAttribute in a vector
Hans Goudey
noreply at git.blender.org
Thu Sep 16 19:03:39 CEST 2021
Commit: ddb7cb7e4ab85d323fe23e4879196f4b1a23d4f5
Author: Hans Goudey
Date: Thu Sep 16 12:03:32 2021 -0500
Branches: master
https://developer.blender.org/rBddb7cb7e4ab85d323fe23e4879196f4b1a23d4f5
Geometry Nodes: Simplify using OutputAttribute in a vector
Store the optional temporary span storage as a unique_ptr and move
it in the move constructor, to avoid the need to add a special move
constructor that clears the "show_warning" fields from it. Maybe this
is very slightly slower, but we'll need this class less often in the future
anyway.
===================================================================
M source/blender/blenkernel/BKE_attribute_access.hh
M source/blender/blenkernel/intern/attribute_access.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh
index 9d309d8a1c1..7a4dc5270af 100644
--- a/source/blender/blenkernel/BKE_attribute_access.hh
+++ b/source/blender/blenkernel/BKE_attribute_access.hh
@@ -247,7 +247,7 @@ class OutputAttribute {
GVMutableArrayPtr varray_;
AttributeDomain domain_;
SaveFn save_;
- std::optional<fn::GVMutableArray_GSpan> optional_span_varray_;
+ std::unique_ptr<fn::GVMutableArray_GSpan> optional_span_varray_;
bool ignore_old_values_ = false;
bool save_has_been_called_ = false;
@@ -265,7 +265,15 @@ class OutputAttribute {
{
}
- OutputAttribute(OutputAttribute &&other) = default;
+ OutputAttribute(OutputAttribute &&other)
+ : varray_(std::move(other.varray_)),
+ domain_(other.domain_),
+ save_(other.save_),
+ optional_span_varray_(std::move(other.optional_span_varray_)),
+ ignore_old_values_(other.ignore_old_values_),
+ save_has_been_called_(other.save_has_been_called_)
+ {
+ }
~OutputAttribute();
@@ -306,9 +314,10 @@ class OutputAttribute {
fn::GMutableSpan as_span()
{
- if (!optional_span_varray_.has_value()) {
+ if (!optional_span_varray_) {
const bool materialize_old_values = !ignore_old_values_;
- optional_span_varray_.emplace(*varray_, materialize_old_values);
+ optional_span_varray_ = std::make_unique<fn::GVMutableArray_GSpan>(*varray_,
+ materialize_old_values);
}
fn::GVMutableArray_GSpan &span_varray = *optional_span_varray_;
return span_varray;
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index cfd3136c765..ee0477faefe 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -190,7 +190,7 @@ AttributeDomain attribute_domain_highest_priority(Span<AttributeDomain> domains)
void OutputAttribute::save()
{
save_has_been_called_ = true;
- if (optional_span_varray_.has_value()) {
+ if (optional_span_varray_) {
optional_span_varray_->save();
}
if (save_) {
More information about the Bf-blender-cvs
mailing list