Blender V5.3
BKE_attribute.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#pragma once
11
12#include <optional>
13#include <string>
14
15#include "BLI_enum_flags.hh"
16#include "BLI_string_ref.hh"
17#include "BLI_sys_types.hh"
18
20
21namespace blender {
22
23namespace bke {
24enum class AttrDomain : int8_t;
28} // namespace bke
29struct BMesh;
30struct CustomData;
31struct CustomDataLayer;
32struct ID;
33struct ReportList;
34struct Mesh;
35struct PointCloud;
36struct Curves;
37struct GreasePencil;
39
50
58
61 void *ptr_ = nullptr;
62
63 public:
65 AttributeOwner(AttributeOwnerType type, void *ptr) : type_(type), ptr_(ptr) {};
66
67 static AttributeOwner from_id(ID *id);
68
70 bool is_valid() const;
71
73 std::optional<bke::MutableAttributeAccessor> get_accessor() const;
74
75 Mesh *get_mesh() const;
77 Curves *get_curves() const;
80};
81
82#define ATTR_DOMAIN_AS_MASK(domain) ((AttrDomainMask)((1 << int(domain))))
83
84/* All domains that support color attributes. */
85#define ATTR_DOMAIN_MASK_COLOR \
86 ((AttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
87
88/* Attributes. */
89
93struct CustomDataLayer *BKE_attribute_new(Mesh &mesh,
94 BMesh &bm,
95 StringRef name,
96 eCustomDataType type,
97 bke::AttrDomain domain,
98 struct ReportList *reports);
99bool BKE_attribute_remove(AttributeOwner &owner, StringRef name, struct ReportList *reports);
100
102 const BMesh &bm,
103 const struct CustomDataLayer *layer);
104int BKE_attribute_domain_size(const AttributeOwner &owner, int domain);
105bool BKE_attribute_required(const AttributeOwner &owner, StringRef name);
107 StringRef old_name,
108 StringRef new_name,
109 struct ReportList *reports);
110
112 AttrDomainMask domain_mask,
114 bool include_anonymous = true);
115
116std::optional<StringRefNull> BKE_attributes_active_name_get(AttributeOwner &owner);
126
127std::optional<StringRef> BKE_attribute_from_index(AttributeOwner &owner,
128 int lookup_index,
129 AttrDomainMask domain_mask,
130 eCustomDataMask layer_mask,
131 bool include_anonymous = true);
132
135 const StringRef name,
136 AttrDomainMask domain_mask,
137 eCustomDataMask layer_mask,
138 bool include_anonymous = true);
139
140std::optional<StringRef> BKE_id_attributes_active_color_name(const struct ID *id);
141std::optional<StringRef> BKE_id_attributes_default_color_name(const struct ID *id);
142void BKE_id_attributes_active_color_set(struct ID *id, std::optional<StringRef> name);
144void BKE_id_attributes_default_color_set(struct ID *id, std::optional<StringRef> name);
145
146bool BKE_id_attributes_color_find(const struct ID *id, StringRef name);
147
148std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, StringRef name);
149
150[[nodiscard]] StringRef BKE_uv_map_pin_name_get(StringRef uv_map_name, char *buffer);
151
152} // namespace blender
GreasePencilDrawing * get_grease_pencil_drawing() const
GreasePencil * get_grease_pencil() const
bke::AttributeStorage * get_storage() const
AttributeOwner(AttributeOwnerType type, void *ptr)
std::optional< bke::MutableAttributeAccessor > get_accessor() const
static AttributeOwner from_id(ID *id)
AttributeOwnerType type() const
#define layer
ENUM_OPERATORS(Layer::Flags)
BMesh Iterators.
std::optional< StringRefNull > BKE_attributes_active_name_get(AttributeOwner &owner)
int * BKE_attributes_active_index_p(AttributeOwner &owner)
bool BKE_attribute_remove(AttributeOwner &owner, StringRef name, struct ReportList *reports)
void BKE_attributes_active_index_validate(AttributeOwner &owner)
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< StringRef > name)
void BKE_id_attributes_active_color_clear(struct ID *id)
std::optional< StringRef > BKE_id_attributes_default_color_name(const struct ID *id)
std::optional< StringRef > BKE_id_attributes_active_color_name(const struct ID *id)
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask, bool include_anonymous=true)
void BKE_attributes_active_set(AttributeOwner &owner, StringRef name)
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, StringRef name)
bool BKE_attribute_rename(AttributeOwner &owner, StringRef old_name, StringRef new_name, struct ReportList *reports)
uint64_t eCustomDataMask
unsigned char uint8_t
Definition BKE_text.h:79
std::optional< StringRef > BKE_attribute_from_index(AttributeOwner &owner, int lookup_index, AttrDomainMask domain_mask, eCustomDataMask layer_mask, bool include_anonymous=true)
bool BKE_attribute_required(const AttributeOwner &owner, StringRef name)
bke::AttrDomain BKE_attribute_domain(const Mesh &mesh, const BMesh &bm, const struct CustomDataLayer *layer)
int BKE_attribute_domain_size(const AttributeOwner &owner, int domain)
@ ATTR_DOMAIN_MASK_CORNER
@ ATTR_DOMAIN_MASK_POINT
@ ATTR_DOMAIN_MASK_ALL
@ ATTR_DOMAIN_MASK_FACE
@ ATTR_DOMAIN_MASK_EDGE
@ ATTR_DOMAIN_MASK_CURVE
@ ATTR_DOMAIN_MASK_GREASE_PENCIL_LAYER
int BKE_attribute_to_index(const AttributeOwner &owner, const StringRef name, AttrDomainMask domain_mask, eCustomDataMask layer_mask, bool include_anonymous=true)
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< StringRef > name)
void BKE_attributes_active_clear(AttributeOwner &owner)
StringRef BKE_uv_map_pin_name_get(StringRef uv_map_name, char *buffer)
signed char int8_t
Definition BKE_text.h:76
struct CustomDataLayer * BKE_attribute_new(Mesh &mesh, BMesh &bm, StringRef name, eCustomDataType type, bke::AttrDomain domain, struct ReportList *reports)
bool BKE_id_attributes_color_find(const struct ID *id, StringRef name)