Commit: 6ba48a78d294fafbe1776096d66c2bd3a176548c Author: Jacques Lucke Date: Tue Apr 13 08:38:01 2021 +0200 Branches: virtual-array-attributes https://developer.blender.org/rB6ba48a78d294fafbe1776096d66c2bd3a176548c
initial typed output attribute =================================================================== M source/blender/blenkernel/BKE_attribute_access.hh =================================================================== diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh index fe901848852..4d234a5a03b 100644 --- a/source/blender/blenkernel/BKE_attribute_access.hh +++ b/source/blender/blenkernel/BKE_attribute_access.hh @@ -114,4 +114,60 @@ class OutputAttribute { void save_if_necessary(); }; +template<typename T> class OutputAttribute_Typed { + private: + OutputAttribute attribute_; + std::optional<fn::GVMutableArray_Typed<T>> optional_varray_; + VMutableArray<T> *varray_ = nullptr; + + public: + OutputAttribute_Typed(OutputAttribute attribute) : attribute_(std::move(attribute)) + { + if (attribute_) { + varray_.emplace(attribute_.varray()); + varray_ = &**optional_varray_; + } + } + + operator bool() const + { + return varray_ != nullptr; + } + + VMutableArray<T> &operator*() + { + return *varray_; + } + + VMutableArray<T> *operator->() + { + return varray_; + } + + GVMutableArray<T> &varray() + { + return *varray_; + } + + AttributeDomain domain() const + { + return attribute_.domain(); + } + + const CPPType &cpp_type() const + { + return CPPType::get<T>(); + } + + CustomDataType custom_data_type() const + { + return cpp_type_to_custom_data_type(this->cpp_type()); + } + + void save_if_necessary() + { + attribute_.save_if_necessary(); + } +}; + } // namespace blender::bke _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs