diff options
Diffstat (limited to 'source/blender/blenkernel/BKE_attribute_access.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_attribute_access.hh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh index c3bc4d3ca4a..381a03d29d7 100644 --- a/source/blender/blenkernel/BKE_attribute_access.hh +++ b/source/blender/blenkernel/BKE_attribute_access.hh @@ -333,6 +333,21 @@ class CustomDataAttributes { void reallocate(const int size); std::optional<blender::fn::GSpan> get_for_read(const blender::StringRef name) const; + + blender::fn::GVArrayPtr get_for_read(const StringRef name, + const CustomDataType data_type, + const void *default_value) const; + + template<typename T> + blender::fn::GVArray_Typed<T> get_for_read(const blender::StringRef name, + const T &default_value) const + { + const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get<T>(); + const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type); + GVArrayPtr varray = this->get_for_read(name, type, &default_value); + return blender::fn::GVArray_Typed<T>(std::move(varray)); + } + std::optional<blender::fn::GMutableSpan> get_for_write(const blender::StringRef name); bool create(const blender::StringRef name, const CustomDataType data_type); bool create_by_move(const blender::StringRef name, const CustomDataType data_type, void *buffer); |