Blender V4.5
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_string_ref.hh"
16#include "BLI_sys_types.h"
17
19
20namespace blender::bke {
21enum class AttrDomain : int8_t;
23} // namespace blender::bke
24struct CustomData;
25struct CustomDataLayer;
26struct ID;
27struct ReportList;
28struct Mesh;
29struct PointCloud;
30struct Curves;
31struct GreasePencil;
33
44
52
55 void *ptr_ = nullptr;
56
57 public:
59 AttributeOwner(AttributeOwnerType type, void *ptr) : type_(type), ptr_(ptr){};
60
61 static AttributeOwner from_id(ID *id);
62
64 bool is_valid() const;
65
66 Mesh *get_mesh() const;
68 Curves *get_curves() const;
71};
72
73#define ATTR_DOMAIN_AS_MASK(domain) ((AttrDomainMask)((1 << (int)(domain))))
74
75/* All domains that support color attributes. */
76#define ATTR_DOMAIN_MASK_COLOR \
77 ((AttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
78
79/* Attributes. */
80
88 struct ReportList *reports);
91 struct ReportList *reports);
92
98 struct ReportList *reports);
99
104
105const struct CustomDataLayer *BKE_attribute_search(const AttributeOwner &owner,
107 eCustomDataMask type,
108 AttrDomainMask domain_mask);
109
112 eCustomDataMask type,
113 AttrDomainMask domain_mask);
114
116 const struct CustomDataLayer *layer);
117int BKE_attribute_domain_size(const AttributeOwner &owner, int domain);
121 blender::StringRef old_name,
122 blender::StringRef new_name,
123 struct ReportList *reports);
124
126 AttrDomainMask domain_mask,
127 eCustomDataMask mask);
128
129std::optional<blender::StringRefNull> BKE_attributes_active_name_get(AttributeOwner &owner);
133
135 struct CustomDataLayer *layers);
137 int lookup_index,
138 AttrDomainMask domain_mask,
139 eCustomDataMask layer_mask);
140
143 const CustomDataLayer *layer,
144 AttrDomainMask domain_mask,
145 eCustomDataMask layer_mask);
146
147std::optional<blender::StringRef> BKE_id_attributes_active_color_name(const struct ID *id);
148std::optional<blender::StringRef> BKE_id_attributes_default_color_name(const struct ID *id);
149void BKE_id_attributes_active_color_set(struct ID *id, std::optional<blender::StringRef> name);
151void BKE_id_attributes_default_color_set(struct ID *id, std::optional<blender::StringRef> name);
152
153const struct CustomDataLayer *BKE_id_attributes_color_find(const struct ID *id,
156
158
160 char *buffer);
162 char *buffer);
164 char *buffer);
void BKE_id_attributes_default_color_set(struct ID *id, std::optional< blender::StringRef > name)
struct CustomDataLayer * BKE_attribute_new(AttributeOwner &owner, blender::StringRef name, eCustomDataType type, blender::bke::AttrDomain domain, struct ReportList *reports)
Definition attribute.cc:391
std::optional< blender::StringRefNull > BKE_attributes_active_name_get(AttributeOwner &owner)
Definition attribute.cc:802
int BKE_attribute_to_index(const AttributeOwner &owner, const CustomDataLayer *layer, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
Definition attribute.cc:932
blender::StringRef BKE_uv_map_pin_name_get(blender::StringRef uv_map_name, char *buffer)
struct CustomDataLayer * BKE_attribute_search_for_write(AttributeOwner &owner, blender::StringRef name, eCustomDataMask type, AttrDomainMask domain_mask)
Definition attribute.cc:690
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:383
blender::bke::AttrDomain BKE_attribute_domain(const AttributeOwner &owner, const struct CustomDataLayer *layer)
struct CustomDataLayer * BKE_attribute_find(const AttributeOwner &owner, blender::StringRef name, eCustomDataType type, blender::bke::AttrDomain domain)
Definition attribute.cc:632
CustomData * BKE_attributes_iterator_next_domain(AttributeOwner &owner, struct CustomDataLayer *layers)
Definition attribute.cc:875
int BKE_attribute_domain_size(const AttributeOwner &owner, int domain)
Definition attribute.cc:751
std::optional< blender::StringRef > BKE_id_attributes_default_color_name(const struct ID *id)
CustomDataLayer * BKE_attribute_from_index(AttributeOwner &owner, int lookup_index, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
Definition attribute.cc:899
bool BKE_attribute_remove(AttributeOwner &owner, blender::StringRef name, struct ReportList *reports)
Definition attribute.cc:523
void BKE_attributes_active_set(AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:838
AttrDomainMask
@ ATTR_DOMAIN_MASK_GREASE_PENCIL_LAYER
@ ATTR_DOMAIN_MASK_POINT
@ ATTR_DOMAIN_MASK_EDGE
@ ATTR_DOMAIN_MASK_ALL
@ ATTR_DOMAIN_MASK_CORNER
@ ATTR_DOMAIN_MASK_CURVE
@ ATTR_DOMAIN_MASK_FACE
const struct CustomDataLayer * BKE_attribute_search(const AttributeOwner &owner, blender::StringRef name, eCustomDataMask type, AttrDomainMask domain_mask)
Definition attribute.cc:657
const struct CustomDataLayer * BKE_id_attributes_color_find(const struct ID *id, blender::StringRef name)
int * BKE_attributes_active_index_p(AttributeOwner &owner)
Definition attribute.cc:853
AttributeOwnerType
void BKE_id_attributes_active_color_clear(struct ID *id)
bool BKE_attribute_required(const AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:785
blender::StringRef BKE_uv_map_edge_select_name_get(blender::StringRef uv_map_name, char *buffer)
int BKE_attribute_data_length(AttributeOwner &owner, struct CustomDataLayer *layer)
Definition attribute.cc:757
std::optional< blender::StringRef > BKE_id_attributes_active_color_name(const struct ID *id)
bool BKE_color_attribute_supported(const struct Mesh &mesh, blender::StringRef name)
blender::StringRef BKE_uv_map_vert_select_name_get(blender::StringRef uv_map_name, char *buffer)
struct CustomDataLayer * BKE_attribute_duplicate(AttributeOwner &owner, blender::StringRef name, struct ReportList *reports)
Definition attribute.cc:455
bool BKE_attribute_rename(AttributeOwner &owner, blender::StringRef old_name, blender::StringRef new_name, struct ReportList *reports)
Definition attribute.cc:267
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask)
Definition attribute.cc:711
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
Definition attribute.cc:986
void BKE_attributes_active_clear(AttributeOwner &owner)
Definition attribute.cc:848
#define ENUM_OPERATORS(_type, _max)
ReportList * reports
Definition WM_types.hh:1025
AttributeOwnerType type() const
Definition attribute.cc:62
AttributeOwner(AttributeOwnerType type, void *ptr)
static AttributeOwner from_id(ID *id)
Definition attribute.cc:43
bool is_valid() const
Definition attribute.cc:67
Mesh * get_mesh() const
Definition attribute.cc:72
GreasePencil * get_grease_pencil() const
Definition attribute.cc:93
PointCloud * get_pointcloud() const
Definition attribute.cc:79
Curves * get_curves() const
Definition attribute.cc:86
GreasePencilDrawing * get_grease_pencil_drawing() const
Definition attribute.cc:100
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
Definition DNA_ID.h:404
PointerRNA * ptr
Definition wm_files.cc:4226