19 const auto &
data = std::get<Attribute::ArrayData>(attribute.
data());
22 data.sharing_info.get()};
25 const auto &
data = std::get<Attribute::SingleData>(attribute.
data());
28 data.sharing_info.get()};
46 std::function<void()> tag_modified_fn;
50 tag_modified_fn = [owner, update_fn]() { update_fn(owner); };
56 std::move(tag_modified_fn)};
71 switch (initializer.
type) {
88 data.size = domain_size;
96 data.size = domain_size;
103 data.data =
const_cast<void *
>(
init.data);
104 data.size = domain_size;
106 data.sharing_info->add_user();
119 const void *default_value)
123 const auto return_default = [&]() {
128 return return_default();
130 if (attr->
domain() != domain) {
131 return return_default();
134 return return_default();
138 const auto &
data = std::get<bke::Attribute::ArrayData>(attr->
data());
143 const auto &
data = std::get<bke::Attribute::SingleData>(attr->
data());
147 return return_default();
160 if (attr->
domain() != domain) {
163 if (
const auto *array_data = std::get_if<bke::Attribute::ArrayData>(&attr->
data())) {
166 return GSpan(cpp_type, array_data->data, array_data->
size);
176 const void *custom_default_value)
178 if (domain_size <= 0) {
183 if (attr->data_type() == type) {
184 if (
const auto *single_data = std::get_if<bke::Attribute::SingleData>(&attr->data())) {
186 const GPointer g_value(cpp_type, single_data->value);
189 auto &array_data = std::get<bke::Attribute::ArrayData>(attr->data_for_write());
190 return GMutableSpan(cpp_type, array_data.data, domain_size);
196 const void *default_value = custom_default_value ? custom_default_value :
203 auto &array_data = std::get<bke::Attribute::ArrayData>(attr.
data_for_write());
205 return GMutableSpan(cpp_type, array_data.data, domain_size);
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
BMesh const char void * data
const void * default_value() const
const CPPType & type() const
void materialize_to_uninitialized(void *dst) const
IndexRange index_range() const
static GVArray from_single(const CPPType &type, int64_t size, const void *value)
static GVArray from_span(GSpan span)
static GVArray from_single_ref(const CPPType &type, int64_t size, const void *value)
static GVMutableArray from_span(GMutableSpan span)
Attribute & add(std::string name, bke::AttrDomain domain, bke::AttrType data_type, Attribute::DataVariant data)
Attribute * lookup(StringRef name)
bool remove(StringRef name)
AttrStorageType storage_type() const
const DataVariant & data() const
std::variant< ArrayData, SingleData > DataVariant
DataVariant & data_for_write()
AttrDomain domain() const
StringRefNull name() const
AttrType data_type() const
void *(* MEM_malloc_arrayN_aligned)(size_t len, size_t size, size_t alignment, const char *str)
GMutableSpan get_mutable_attribute(AttributeStorage &storage, const AttrDomain domain, const CPPType &cpp_type, const StringRef name, const int64_t domain_size, const void *custom_default_value)
GAttributeReader attribute_to_reader(const Attribute &attribute, const AttrDomain domain, const int64_t domain_size)
std::optional< GSpan > get_span_attribute(const AttributeStorage &storage, const AttrDomain domain, const CPPType &cpp_type, const StringRef name, const int64_t domain_size)
Attribute::DataVariant attribute_init_to_data(const bke::AttrType data_type, const int64_t domain_size, const AttributeInit &initializer)
GAttributeWriter attribute_to_writer(void *owner, const Map< StringRef, AttrUpdateOnChange > &changed_tags, const int64_t domain_size, Attribute &attribute)
GVArray get_varray_attribute(const AttributeStorage &storage, AttrDomain domain, const CPPType &cpp_type, StringRef name, int64_t domain_size, const void *default_value)
void(*)(void *owner) AttrUpdateOnChange
static const auto & changed_tags()
AttrType cpp_type_to_attribute_type(const CPPType &type)
const CPPType & attribute_type_to_cpp_type(AttrType type)
const ImplicitSharingInfo * info_for_mem_free(void *data)
static void init(bNodeTree *, bNode *node)
static ArrayData from_default_value(const CPPType &type, int64_t domain_size)
static ArrayData from_value(const GPointer &value, int64_t domain_size)
static ArrayData from_constructed(const CPPType &type, int64_t domain_size)