Blender V5.3
attribute_storage_access.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BKE_attribute.hh"
11
12#include "DNA_meshdata_types.h"
13#include "DNA_object_types.h"
14
15#include <optional>
16
17namespace blender::bke {
18
19using AttrUpdateOnChange = void (*)(void *owner);
20
29
31 const AttrDomain domain,
32 const int64_t domain_size);
33
35 const Map<StringRef, AttrUpdateOnChange> &changed_tags,
36 const int64_t domain_size,
38
40 const int64_t domain_size,
41 const AttributeInit &initializer,
42 bool require_array_data);
43
45 AttrDomain domain,
46 const CPPType &cpp_type,
47 StringRef name,
48 int64_t domain_size,
49 const void *default_value);
50
51template<typename T>
53 const AttrDomain domain,
54 const StringRef name,
55 const int64_t domain_size,
56 const T &default_value)
57{
59 storage, domain, CPPType::get<T>(), name, domain_size, &default_value);
60 return varray.typed<T>();
61}
62
63std::optional<GSpan> get_span_attribute(const AttributeStorage &storage,
64 AttrDomain domain,
65 const CPPType &cpp_type,
66 StringRef name,
67 const int64_t domain_size);
68
69template<typename T>
70inline std::optional<Span<T>> get_span_attribute(const AttributeStorage &storage,
71 const AttrDomain domain,
72 const StringRef name,
73 const int64_t domain_size)
74{
75 const std::optional<GSpan> span = get_span_attribute(
76 storage, domain, CPPType::get<T>(), name, domain_size);
77 if (!span) {
78 return std::nullopt;
79 }
80 return span->typed<T>();
81}
82
84 const AttrDomain domain,
85 const CPPType &cpp_type,
86 const StringRef name,
87 const int64_t domain_size,
88 const void *default_value);
89
90template<typename T>
92 const AttrDomain domain,
93 const StringRef name,
94 const int64_t domain_size,
95 const T &default_value = T())
96{
98 storage, domain, CPPType::get<T>(), name, domain_size, &default_value);
99 return span.typed<T>();
100}
101
102bool try_delete_vertex_group(ListBaseT<bDeformGroup> &vertex_groups,
103 StringRef name,
104 FunctionRef<MutableSpan<MDeformVert>()> get_mutable_dverts);
105
107 const Map<StringRef, StringRef> &name_map,
108 bool overwrite,
109 const Map<StringRef, AttrBuiltinInfo> &builtin_attributes,
110 const Set<StringRef> &array_storage_required,
111 FunctionRef<int(AttrDomain)> domain_size_fn,
112 std::optional<ListBaseT<bDeformGroup> *> vertex_groups,
113 FunctionRef<MutableSpan<MDeformVert>()> get_mutable_dverts);
114
115} // namespace blender::bke
Object is a sort of wrapper for general info.
static const CPPType & get()
MutableSpan< T > typed() const
std::variant< ArrayData, SingleData > DataVariant
#define storage(slot, qualifiers)
#define attribute(slot)
#define T
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)
Set< StringRef > rename_attributes(AttributeStorage &storage, const Map< StringRef, StringRef > &name_map, const bool overwrite, const Map< StringRef, AttrBuiltinInfo > &builtin_attributes, const Set< StringRef > &array_storage_required, const FunctionRef< int(AttrDomain)> domain_size_fn, std::optional< ListBaseT< bDeformGroup > * > vertex_groups, FunctionRef< MutableSpan< MDeformVert >()> get_mutable_dverts)
GAttributeWriter attribute_to_writer(void *owner, const Map< StringRef, AttrUpdateOnChange > &changed_tags, const int64_t domain_size, Attribute &attribute)
bool try_delete_vertex_group(ListBaseT< bDeformGroup > &vertex_groups, const StringRef name, FunctionRef< MutableSpan< MDeformVert >()> get_mutable_dverts)
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
Attribute::DataVariant attribute_init_to_data(const bke::AttrType data_type, const int64_t domain_size, const AttributeInit &initializer, const bool require_array_data)
__int64 int64_t
Definition BKE_text.h:90
AttrBuiltinInfo(AttrDomain domain, AttrType type)