Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/BKE_attribute_access.hh
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| #pragma once | #pragma once | ||||
| #include <mutex> | #include <mutex> | ||||
| #include "FN_cpp_type.hh" | |||||
| #include "FN_generic_span.hh" | #include "FN_generic_span.hh" | ||||
| #include "FN_generic_virtual_array.hh" | #include "FN_generic_virtual_array.hh" | ||||
| #include "BKE_anonymous_attribute.hh" | #include "BKE_anonymous_attribute.hh" | ||||
| #include "BKE_attribute.h" | #include "BKE_attribute.h" | ||||
| #include "BLI_color.hh" | #include "BLI_color.hh" | ||||
| #include "BLI_function_ref.hh" | #include "BLI_function_ref.hh" | ||||
| ▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| /* Returns false when the iteration should be stopped. */ | /* Returns false when the iteration should be stopped. */ | ||||
| using AttributeForeachCallback = blender::FunctionRef<bool( | using AttributeForeachCallback = blender::FunctionRef<bool( | ||||
| const blender::bke::AttributeIDRef &attribute_id, const AttributeMetaData &meta_data)>; | const blender::bke::AttributeIDRef &attribute_id, const AttributeMetaData &meta_data)>; | ||||
| namespace blender::bke { | namespace blender::bke { | ||||
| using fn::CPPType; | |||||
| using fn::GVArray; | using fn::GVArray; | ||||
| using fn::GVMutableArray; | using fn::GVMutableArray; | ||||
| const CPPType *custom_data_type_to_cpp_type(const CustomDataType type); | const CPPType *custom_data_type_to_cpp_type(const CustomDataType type); | ||||
| CustomDataType cpp_type_to_custom_data_type(const CPPType &type); | CustomDataType cpp_type_to_custom_data_type(const CPPType &type); | ||||
| CustomDataType attribute_data_type_highest_complexity(Span<CustomDataType> data_types); | CustomDataType attribute_data_type_highest_complexity(Span<CustomDataType> data_types); | ||||
| /** | /** | ||||
| * Domains with a higher "information density" have a higher priority, | * Domains with a higher "information density" have a higher priority, | ||||
| ▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | public: | ||||
| */ | */ | ||||
| blender::fn::GVArray get_for_read(const AttributeIDRef &attribute_id, | blender::fn::GVArray get_for_read(const AttributeIDRef &attribute_id, | ||||
| const CustomDataType data_type, | const CustomDataType data_type, | ||||
| const void *default_value) const; | const void *default_value) const; | ||||
| template<typename T> | template<typename T> | ||||
| blender::VArray<T> get_for_read(const AttributeIDRef &attribute_id, const T &default_value) const | blender::VArray<T> get_for_read(const AttributeIDRef &attribute_id, const T &default_value) const | ||||
| { | { | ||||
| const blender::fn::CPPType &cpp_type = blender::fn::CPPType::get<T>(); | const blender::CPPType &cpp_type = blender::CPPType::get<T>(); | ||||
| const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type); | const CustomDataType type = blender::bke::cpp_type_to_custom_data_type(cpp_type); | ||||
| GVArray varray = this->get_for_read(attribute_id, type, &default_value); | GVArray varray = this->get_for_read(attribute_id, type, &default_value); | ||||
| return varray.typed<T>(); | return varray.typed<T>(); | ||||
| } | } | ||||
| std::optional<blender::fn::GMutableSpan> get_for_write(const AttributeIDRef &attribute_id); | std::optional<blender::fn::GMutableSpan> get_for_write(const AttributeIDRef &attribute_id); | ||||
| bool create(const AttributeIDRef &attribute_id, const CustomDataType data_type); | bool create(const AttributeIDRef &attribute_id, const CustomDataType data_type); | ||||
| bool create_by_move(const AttributeIDRef &attribute_id, | bool create_by_move(const AttributeIDRef &attribute_id, | ||||
| ▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines | |||||