Blender V5.0
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;
25} // namespace blender::bke
26struct CustomData;
27struct CustomDataLayer;
28struct ID;
29struct ReportList;
30struct Mesh;
31struct PointCloud;
32struct Curves;
33struct GreasePencil;
35
46
54
57 void *ptr_ = nullptr;
58
59 public:
61 AttributeOwner(AttributeOwnerType type, void *ptr) : type_(type), ptr_(ptr) {};
62
63 static AttributeOwner from_id(ID *id);
64
66 bool is_valid() const;
67
69 std::optional<blender::bke::MutableAttributeAccessor> get_accessor() const;
70
71 Mesh *get_mesh() const;
73 Curves *get_curves() const;
76};
77
78#define ATTR_DOMAIN_AS_MASK(domain) ((AttrDomainMask)((1 << (int)(domain))))
79
80/* All domains that support color attributes. */
81#define ATTR_DOMAIN_MASK_COLOR \
82 ((AttrDomainMask)((ATTR_DOMAIN_MASK_POINT | ATTR_DOMAIN_MASK_CORNER)))
83
84/* Attributes. */
85
93 struct ReportList *reports);
96 struct ReportList *reports);
97
103 struct ReportList *reports);
104
109
110const struct CustomDataLayer *BKE_attribute_search(const AttributeOwner &owner,
112 eCustomDataMask type,
113 AttrDomainMask domain_mask);
114
117 eCustomDataMask type,
118 AttrDomainMask domain_mask);
119
121 const struct CustomDataLayer *layer);
122int BKE_attribute_domain_size(const AttributeOwner &owner, int domain);
126 blender::StringRef old_name,
127 blender::StringRef new_name,
128 struct ReportList *reports);
129
131 AttrDomainMask domain_mask,
132 eCustomDataMask mask);
133
134std::optional<blender::StringRefNull> BKE_attributes_active_name_get(AttributeOwner &owner);
138
140 struct CustomDataLayer *layers);
142 int lookup_index,
143 AttrDomainMask domain_mask,
144 eCustomDataMask layer_mask);
145
148 const CustomDataLayer *layer,
149 AttrDomainMask domain_mask,
150 eCustomDataMask layer_mask);
151
152std::optional<blender::StringRef> BKE_id_attributes_active_color_name(const struct ID *id);
153std::optional<blender::StringRef> BKE_id_attributes_default_color_name(const struct ID *id);
154void BKE_id_attributes_active_color_set(struct ID *id, std::optional<blender::StringRef> name);
156void BKE_id_attributes_default_color_set(struct ID *id, std::optional<blender::StringRef> name);
157
158const struct CustomDataLayer *BKE_id_attributes_color_find(const struct ID *id,
161
163
165 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:382
std::optional< blender::StringRefNull > BKE_attributes_active_name_get(AttributeOwner &owner)
Definition attribute.cc:784
int BKE_attribute_to_index(const AttributeOwner &owner, const CustomDataLayer *layer, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
Definition attribute.cc:931
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:672
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:370
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:614
CustomData * BKE_attributes_iterator_next_domain(AttributeOwner &owner, struct CustomDataLayer *layers)
Definition attribute.cc:874
int BKE_attribute_domain_size(const AttributeOwner &owner, int domain)
Definition attribute.cc:733
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:898
bool BKE_attribute_remove(AttributeOwner &owner, blender::StringRef name, struct ReportList *reports)
Definition attribute.cc:512
void BKE_attributes_active_set(AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:830
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:639
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:852
AttributeOwnerType
void BKE_id_attributes_active_color_clear(struct ID *id)
bool BKE_attribute_required(const AttributeOwner &owner, blender::StringRef name)
Definition attribute.cc:767
int BKE_attribute_data_length(AttributeOwner &owner, struct CustomDataLayer *layer)
Definition attribute.cc:739
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)
struct CustomDataLayer * BKE_attribute_duplicate(AttributeOwner &owner, blender::StringRef name, struct ReportList *reports)
Definition attribute.cc:451
bool BKE_attribute_rename(AttributeOwner &owner, blender::StringRef old_name, blender::StringRef new_name, struct ReportList *reports)
Definition attribute.cc:251
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask)
Definition attribute.cc:693
void BKE_id_attributes_active_color_set(struct ID *id, std::optional< blender::StringRef > name)
Definition attribute.cc:985
void BKE_attributes_active_clear(AttributeOwner &owner)
Definition attribute.cc:847
#define ENUM_OPERATORS(_type, _max)
AttributeOwnerType type() const
Definition attribute.cc:63
AttributeOwner(AttributeOwnerType type, void *ptr)
std::optional< blender::bke::MutableAttributeAccessor > get_accessor() const
Definition attribute.cc:126
static AttributeOwner from_id(ID *id)
Definition attribute.cc:44
bool is_valid() const
Definition attribute.cc:68
Mesh * get_mesh() const
Definition attribute.cc:73
GreasePencil * get_grease_pencil() const
Definition attribute.cc:94
PointCloud * get_pointcloud() const
Definition attribute.cc:80
Curves * get_curves() const
Definition attribute.cc:87
GreasePencilDrawing * get_grease_pencil_drawing() const
Definition attribute.cc:101
blender::bke::AttributeStorage * get_storage() const
Definition attribute.cc:108
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
const char * name
Definition DNA_ID.h:414
PointerRNA * ptr
Definition wm_files.cc:4238