49 switch (
GS(
id->name)) {
70 return ptr_ !=
nullptr;
77 return reinterpret_cast<Mesh *
>(ptr_);
91 return reinterpret_cast<Curves *
>(ptr_);
116 return &this->
get_curves()->geometry.attribute_storage.wrap();
132 return this->
get_mesh()->attributes_for_write();
136 return this->
get_curves()->geometry.wrap().attributes_for_write();
153 std::array<DomainInfo, ATTR_DOMAIN_NUM> info;
154 info[int(AttrDomain::Point)].customdata = &
bm->
vdata;
155 info[int(AttrDomain::Point)].length =
bm->
totvert;
156 info[int(AttrDomain::Edge)].customdata = &
bm->
edata;
157 info[int(AttrDomain::Edge)].length =
bm->
totedge;
158 info[int(AttrDomain::Corner)].customdata = &
bm->
ldata;
159 info[int(AttrDomain::Corner)].length =
bm->
totloop;
160 info[int(AttrDomain::Face)].customdata = &
bm->
pdata;
161 info[int(AttrDomain::Face)].length =
bm->
totface;
171 if (!
storage.lookup(old_name)) {
200 "Domain unsupported for \"%s\" attribute",
201 std::string(name).c_str());
204 if (data_type !=
metadata->data_type) {
206 reports,
RPT_ERROR,
"Type unsupported for \"%s\" attribute", std::string(name).c_str());
219 if (
mesh.runtime->edit_mesh) {
257 if (old_name == new_name_clamped) {
337 if (old_name ==
mesh->active_uv_map_name()) {
338 mesh->uv_maps_active_set(new_name);
340 if (old_name ==
mesh->default_uv_map_name()) {
341 mesh->uv_maps_default_set(new_name);
345 attributes.
rename(old_name, new_name);
358 const auto is_used_vertex_group = [&](
const StringRef check_name) {
381 is_used_vertex_group(new_name);
393 return storage.lookup(check_name) !=
nullptr || is_used_vertex_group(check_name);
400 return storage.unique_name_calc(name_final);
412 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(&
bm);
414 CustomData *customdata = info[int(domain)].customdata;
415 if (customdata ==
nullptr) {
474 "Attribute '%s' is required and cannot be removed",
475 std::string(name).c_str());
482 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(
bm);
485 const std::string name_copy = name;
487 if (layer_index == -1) {
492 const bool is_active_uv_attribute = name_copy ==
mesh->active_uv_map_name();
493 const bool is_default_uv_attribute = name_copy ==
mesh->default_uv_map_name();
494 const bool is_active_color_attribute = name_copy.c_str() ==
496 const bool is_default_color_attribute = name_copy.c_str() ==
500 mesh->default_color_attribute);
508 if (is_active_color_attribute) {
513 if (is_default_color_attribute) {
518 if (is_active_uv_attribute) {
519 mesh->uv_maps_active_set(
522 if (is_default_uv_attribute) {
523 mesh->uv_maps_default_set(
538 std::optional<MutableAttributeAccessor> attributes = owner.
get_accessor();
544 const std::string name_copy = name;
545 std::optional<bke::AttributeMetaData>
metadata = attributes->lookup_meta_data(name_copy);
551 const bool is_active_color_attribute = name_copy ==
StringRef(
mesh->active_color_attribute);
552 const bool is_default_color_attribute = name_copy ==
StringRef(
mesh->default_color_attribute);
553 const bool is_active_uv_attribute = name_copy ==
mesh->active_uv_map_name();
554 const bool is_default_uv_attribute = name_copy ==
mesh->default_uv_map_name();
560 if (!attributes->remove(name_copy)) {
564 if (is_active_color_attribute) {
568 if (is_default_color_attribute) {
572 if (is_active_uv_attribute) {
575 if (is_default_uv_attribute) {
576 mesh->uv_maps_default_set(
587 return attributes->remove(name);
593 const bool include_anonymous)
598 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(
const_cast<BMesh *
>(
bm));
601 const CustomData *customdata = info[domain].customdata;
602 if (customdata ==
nullptr) {
605 if (!customdata || !((1 <<
int(domain)) & domain_mask)) {
626 if (!(ATTR_DOMAIN_AS_MASK(attr.domain()) & domain_mask)) {
643 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(&
const_cast<BMesh &
>(
bm));
646 const CustomData *customdata = info[domain].customdata;
647 if (customdata ==
nullptr) {
664 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(
const_cast<BMesh *
>(
bm));
665 return info[domain].length;
674 switch (owner.
type()) {
693 if (active_index == -1) {
702 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(
const_cast<BMesh *
>(
bm));
705 CustomData *customdata = info[domain].customdata;
706 if (customdata ==
nullptr) {
709 for (
int i = 0; i < customdata->
totlayer; i++) {
712 if (
index == active_index) {
730 return storage.at_index(active_index).name();
738 if (
mesh->runtime->edit_mesh) {
757 switch (owner.
type()) {
765 return &owner.
get_curves()->geometry.attributes_active_index;
780 if (*active_index < 0) {
787 if (attributes_num == 0) {
794 int index_check = *active_index;
795 while (index_check >= 0) {
796 if (index_check < attributes_num) {
799 if (attribute_name_check.has_value() &&
802 *active_index = index_check;
810 index_check = *active_index + 1;
811 while (index_check < attributes_num) {
814 if (attribute_name_check.has_value() &&
817 *active_index = index_check;
828 const int lookup_index,
831 const bool include_anonymous)
836 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(
const_cast<BMesh *
>(
bm));
840 CustomData *customdata = info[domain].customdata;
841 if (!customdata || !((1 <<
int(domain)) & domain_mask)) {
851 if (
index == lookup_index) {
863 return storage.at_index(lookup_index).name();
876 if (
index == lookup_index) {
888 const bool include_anonymous)
893 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(
const_cast<BMesh *
>(
bm));
896 const CustomData *customdata = info[domain].customdata;
897 if (!customdata || !((1 <<
int(domain)) & domain_mask)) {
907 if (
layer.name == name) {
932 if (attr.name() == name) {
943 return reinterpret_cast<const Mesh *
>(
id)->active_color_attribute;
951 return reinterpret_cast<const Mesh *
>(
id)->default_color_attribute;
958 switch (
GS(
id->name)) {
961 MEM_SAFE_DELETE(
mesh->active_color_attribute);
963 mesh->active_color_attribute =
BLI_strdupn(name->data(), name->size());
974 switch (
GS(
id->name)) {
977 MEM_SAFE_DELETE(
mesh->active_color_attribute);
987 switch (
GS(
id->name)) {
990 MEM_SAFE_DELETE(
mesh->default_color_attribute);
992 mesh->default_color_attribute =
BLI_strdupn(name->data(), name->size());
#define ATTR_DOMAIN_MASK_COLOR
#define ATTR_DOMAIN_AS_MASK(domain)
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
Low-level operations for grease pencil.
General operations for point clouds.
ID and Library types, which are fundamental for SDNA.
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
#define MAX_CUSTOMDATA_LAYER_NAME
#define CD_MASK_PROP_FLOAT2
#define CD_MASK_COLOR_ALL
PointCloud * get_pointcloud() const
GreasePencilDrawing * get_grease_pencil_drawing() const
GreasePencil * get_grease_pencil() const
bke::AttributeStorage * get_storage() const
std::optional< bke::MutableAttributeAccessor > get_accessor() const
static AttributeOwner from_id(ID *id)
AttributeOwnerType type() const
Curves * get_curves() const
constexpr IndexRange()=default
constexpr bool contains(int64_t value) const
bool contains(const Key &key) const
std::optional< AttributeDomainAndType > get_builtin_domain_and_type(const StringRef name) const
int domain_size(const AttrDomain domain) const
void rename(StringRef old_name, std::string new_name)
Attribute * lookup(StringRef name)
int index_of(StringRef name) const
AttrDomain domain() const
StringRefNull name() const
AttrType data_type() const
constexpr bool is_empty() const
constexpr int64_t size() const
void copy_unsafe(char *dst) const
void copy_utf8_truncated(char *dst, int64_t dst_size) const
#define storage(slot, qualifiers)
float length(VecOp< float, D >) RET
bool is_uv_map(const AttributeMetaData &meta_data)
std::optional< eCustomDataType > attr_type_to_custom_data_type(AttrType attr_type)
bool attribute_name_is_anonymous(const StringRef name)
bool allow_procedural_attribute_access(StringRef attribute_name)
std::optional< AttrType > custom_data_type_to_attr_type(eCustomDataType data_type)
std::optional< StringRefNull > BKE_attributes_active_name_get(AttributeOwner &owner)
bool BM_data_layer_free_named(BMesh *bm, CustomData *data, StringRef name)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
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)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
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)
bool BKE_grease_pencil_drawing_attribute_required(const GreasePencilDrawing *, StringRef name)
static bool name_valid_for_builtin_domain_and_type(const bke::AttributeAccessor attributes, const StringRef name, const AttrDomain domain, const bke::AttrType data_type, ReportList *reports)
static StringRef color_name_from_index(AttributeOwner &owner, int index)
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask, bool include_anonymous=true)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_attributes_active_set(AttributeOwner &owner, StringRef name)
bool BKE_mesh_attribute_required(StringRef name)
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, StringRef name)
int BKE_defgroup_name_index(const ListBaseT< bDeformGroup > *defbase, StringRef name)
bool BKE_attribute_rename(AttributeOwner &owner, StringRef old_name, StringRef new_name, struct ReportList *reports)
size_t void BLI_uniquename_cb(FunctionRef< bool(StringRefNull)> unique_check, const char *defname, char delim, char *name, size_t name_maxncpy) ATTR_NONNULL(2
static int color_name_to_index(AttributeOwner &owner, const StringRef name)
void BKE_report(ReportList *reports, eReportType type, const char *message)
static int color_clamp_index(AttributeOwner &owner, int index)
BMesh const char void * data
static int uv_name_to_index(AttributeOwner &owner, const StringRef name)
BMDataLayerLookup BM_data_layer_lookup(const BMesh &bm, const StringRef name)
eCustomDataMask CD_TYPE_AS_MASK(eCustomDataType type)
bool BKE_curves_attribute_required(const struct Curves *curves, StringRef name)
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)
int CustomData_get_named_layer_index(const CustomData *data, eCustomDataType type, StringRef name)
static StringRef uv_name_from_index(AttributeOwner &owner, int index)
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)
int CustomData_name_maxncpy_calc(StringRef name)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
@ ATTR_DOMAIN_MASK_CORNER
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)
static int uv_clamp_index(AttributeOwner &owner, int index)
ID_Type GS(const char *name)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const StringRef name)
static bool bke_attribute_rename_if_exists(AttributeOwner &owner, const StringRef old_name, const StringRef new_name, ReportList *reports)
void BKE_attributes_active_clear(AttributeOwner &owner)
int CustomData_get_named_layer_index_notype(const CustomData *data, StringRef name)
StringRef BKE_uv_map_pin_name_get(StringRef uv_map_name, char *buffer)
MINLINE int min_ii(int a, int b)
static std::array< DomainInfo, ATTR_DOMAIN_NUM > get_domains(BMesh *bm)
bool BM_attribute_stored_in_bmesh_builtin(const StringRef name)
static bool mesh_attribute_valid(const Mesh &mesh, const StringRef name, const AttrDomain domain, const bke::AttrType data_type, ReportList *reports)
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)
bool BKE_pointcloud_attribute_required(const PointCloud *pointcloud, StringRef name)
const CustomDataLayer * layer
struct AttributeStorage attribute_storage
int attributes_active_index
struct AttributeStorage attribute_storage
int attributes_active_index
int attributes_active_index
struct AttributeStorage attribute_storage