48 switch (
GS(id->name)) {
69 return ptr_ !=
nullptr;
76 return reinterpret_cast<Mesh *
>(ptr_);
90 return reinterpret_cast<Curves *
>(ptr_);
114 std::array<DomainInfo, ATTR_DOMAIN_NUM> info;
116 switch (owner.
type()) {
119 info[
int(AttrDomain::Point)].customdata = &pointcloud->
pdata;
120 info[
int(AttrDomain::Point)].length = pointcloud->
totpoint;
125 if (
BMEditMesh *em = mesh->runtime->edit_mesh.get()) {
127 info[
int(AttrDomain::Point)].customdata = &
bm->
vdata;
129 info[
int(AttrDomain::Edge)].customdata = &
bm->
edata;
131 info[
int(AttrDomain::Corner)].customdata = &
bm->
ldata;
133 info[
int(AttrDomain::Face)].customdata = &
bm->
pdata;
137 info[
int(AttrDomain::Point)].customdata = &mesh->vert_data;
138 info[
int(AttrDomain::Point)].length = mesh->verts_num;
139 info[
int(AttrDomain::Edge)].customdata = &mesh->edge_data;
140 info[
int(AttrDomain::Edge)].length = mesh->edges_num;
141 info[
int(AttrDomain::Corner)].customdata = &mesh->corner_data;
142 info[
int(AttrDomain::Corner)].length = mesh->corners_num;
143 info[
int(AttrDomain::Face)].customdata = &mesh->face_data;
144 info[
int(AttrDomain::Face)].length = mesh->faces_num;
151 info[
int(AttrDomain::Point)].length = curves->geometry.point_num;
152 info[
int(AttrDomain::Curve)].customdata = &curves->geometry.curve_data;
153 info[
int(AttrDomain::Curve)].length = curves->geometry.curve_num;
158 info[
int(AttrDomain::Layer)].customdata = &grease_pencil->
layers_data;
159 info[
int(AttrDomain::Layer)].length = grease_pencil->layers().size();
180 switch (owner.
type()) {
184 BLI_assert(mesh.runtime->edit_mesh ==
nullptr);
185 return mesh.attributes_for_write();
189 return pointcloud.attributes_for_write();
198 return grease_pencil.attributes_for_write();
211 const char *old_name,
212 const char *new_name,
217 if (layer ==
nullptr) {
224 const AttrDomain domain,
241 if (domain != AttrDomain::Point) {
254 const char *old_name,
255 const char *new_name,
263 if (
STREQ(new_name,
"")) {
276 if (
STREQ(old_name, new_name_clamped)) {
283 if (layer ==
nullptr) {
290 if (mesh->runtime->edit_mesh) {
339 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
342 if (!info[domain].customdata) {
346 const CustomData *cdata = info[domain].customdata;
347 for (
int i = 0; i < cdata->
totlayer; i++) {
350 if (layer->name == name) {
365 name.is_empty() ?
DATA_(
"Attribute") : name);
371 const AttrDomain domain,
375 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
378 if (customdata ==
nullptr) {
387 if (
BMEditMesh *em = mesh->runtime->edit_mesh.get()) {
393 return (index == -1) ? nullptr : &(customdata->
layers[index]);
397 std::optional<MutableAttributeAccessor> attributes = get_attribute_accessor_for_write(owner);
409 return (index == -1) ? nullptr : &(customdata->
layers[index]);
418 std::optional<MutableAttributeAccessor> attributes = get_attribute_accessor_for_write(owner);
441 if (mesh->runtime->edit_mesh) {
447 std::optional<MutableAttributeAccessor> attributes = get_attribute_accessor_for_write(owner);
491 return min_ii(index, length - 1);
498 return layer ? layer->name :
nullptr;
505 if (!name || name[0] ==
'\0') {
514 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
518 if (
BMEditMesh *em = mesh->runtime->edit_mesh.get()) {
520 if (
CustomData *data = info[domain].customdata) {
521 const std::string name_copy = name;
523 if (layer_index == -1) {
528 const bool is_active_color_attribute = name_copy.c_str() ==
530 const bool is_default_color_attribute = name_copy.c_str() ==
531 StringRef(mesh->default_color_attribute);
534 mesh->default_color_attribute);
540 if (is_active_color_attribute) {
545 if (is_default_color_attribute) {
551 if (type ==
CD_PROP_FLOAT2 && domain ==
int(AttrDomain::Corner)) {
567 std::optional<MutableAttributeAccessor> attributes = get_attribute_accessor_for_write(owner);
573 const std::string name_copy = name;
574 std::optional<blender::bke::AttributeMetaData> metadata = attributes->lookup_meta_data(
581 const bool is_active_color_attribute = name_copy ==
StringRef(mesh->active_color_attribute);
582 const bool is_default_color_attribute = name_copy ==
StringRef(mesh->default_color_attribute);
586 if (!attributes->remove(name_copy)) {
590 if (is_active_color_attribute) {
594 if (is_default_color_attribute) {
599 if (metadata->data_type ==
CD_PROP_FLOAT2 && metadata->domain == AttrDomain::Corner) {
608 return attributes->remove(name);
614 const AttrDomain domain)
619 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
622 if (customdata ==
nullptr) {
626 for (
int i = 0; i < customdata->
totlayer; i++) {
628 if (layer->type == type &&
STREQ(layer->name, name)) {
638 const eCustomDataMask type_mask,
644 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
647 domain = AttrDomain(
int(domain) + 1))
654 if (customdata ==
nullptr) {
658 for (
int i = 0; i < customdata->
totlayer; i++) {
671 const eCustomDataMask type_mask,
682 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
692 eCustomDataMask mask)
694 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
699 const CustomData *customdata = info[domain].customdata;
700 if (customdata ==
nullptr) {
704 if ((1 <<
int(domain)) & domain_mask) {
714 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
717 const CustomData *customdata = info[domain].customdata;
718 if (customdata ==
nullptr) {
722 return AttrDomain(domain);
727 return AttrDomain(AttrDomain::Point);
732 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
733 return info[domain].length;
743 if (mesh->runtime->edit_mesh !=
nullptr) {
748 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
751 const CustomData *customdata = info[domain].customdata;
752 if (customdata ==
nullptr) {
756 return info[domain].length;
766 switch (owner.
type()) {
784 if (active_index == -1) {
791 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
796 CustomData *customdata = info[domain].customdata;
797 if (customdata ==
nullptr) {
800 for (
int i = 0; i < customdata->
totlayer; i++) {
803 if (index == active_index) {
834 switch (owner.
type()) {
856 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
858 bool use_next = (layers ==
nullptr);
861 CustomData *customdata = info[domain].customdata;
862 if (customdata ==
nullptr) {
866 if (customdata->
layers == layers) {
881 eCustomDataMask layer_mask)
883 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
887 CustomData *customdata = info[domain].customdata;
889 if (!customdata || !((1 <<
int(domain)) & domain_mask)) {
893 for (
int i = 0; i < customdata->
totlayer; i++) {
900 if (index == lookup_index) {
901 return customdata->
layers + i;
914 eCustomDataMask layer_mask)
920 const std::array<DomainInfo, ATTR_DOMAIN_NUM> info =
get_domains(owner);
924 const CustomData *customdata = info[domain].customdata;
926 if (!customdata || !((1 <<
int(domain)) & domain_mask)) {
930 for (
int i = 0; i < customdata->
totlayer; i++) {
938 if (layer == layer_iter) {
952 return reinterpret_cast<const Mesh *
>(id)->active_color_attribute;
960 return reinterpret_cast<const Mesh *
>(id)->default_color_attribute;
967 switch (
GS(id->name)) {
969 Mesh *mesh =
reinterpret_cast<Mesh *
>(id);
972 mesh->active_color_attribute =
BLI_strdup(name);
983 switch (
GS(id->name)) {
985 Mesh *mesh =
reinterpret_cast<Mesh *
>(id);
996 switch (
GS(id->name)) {
998 Mesh *mesh =
reinterpret_cast<Mesh *
>(id);
1001 mesh->default_color_attribute =
BLI_strdup(name);
1018 std::optional<blender::bke::AttributeMetaData> meta_data = mesh.attributes().lookup_meta_data(
#define ATTR_DOMAIN_MASK_COLOR
#define ATTR_DOMAIN_AS_MASK(domain)
bool BKE_curves_attribute_required(const struct Curves *curves, const char *name)
Low-level operations for curves.
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_named_layer_index_notype(const CustomData *data, blender::StringRef name)
int CustomData_number_of_layers_typemask(const CustomData *data, eCustomDataMask mask)
int CustomData_get_named_layer_index(const CustomData *data, eCustomDataType type, blender::StringRef name)
int CustomData_name_maxncpy_calc(blender::StringRef name)
void CustomData_ensure_data_is_mutable(CustomDataLayer *layer, int totelem)
#define CD_TYPE_AS_MASK(_type)
Low-level operations for grease pencil.
bool BKE_grease_pencil_drawing_attribute_required(const GreasePencilDrawing *, const char *name)
bool BKE_mesh_attribute_required(const char *name)
General operations for point clouds.
bool BKE_pointcloud_attribute_required(const PointCloud *pointcloud, const char *name)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
MINLINE int min_ii(int a, int b)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
size_t void BLI_uniquename_cb(UniquenameCheckCallback unique_check, void *arg, const char *defname, char delim, char *name, size_t name_maxncpy) ATTR_NONNULL(1
ID and Library types, which are fundamental for SDNA.
#define MAX_CUSTOMDATA_LAYER_NAME
#define CD_MASK_COLOR_ALL
Read Guarded memory(de)allocation.
static bool bke_attribute_rename_if_exists(AttributeOwner &owner, const char *old_name, const char *new_name, ReportList *reports)
const CustomDataLayer * BKE_id_attributes_color_find(const ID *id, const char *name)
static bool mesh_edit_mode_attribute_valid(const blender::StringRef name, const AttrDomain domain, const eCustomDataType data_type, ReportList *reports)
const char * BKE_id_attributes_default_color_name(const ID *id)
CustomData * BKE_attributes_iterator_next_domain(AttributeOwner &owner, CustomDataLayer *layers)
static int color_clamp_index(AttributeOwner &owner, int index)
int BKE_attribute_to_index(const AttributeOwner &owner, const CustomDataLayer *layer, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
static int color_name_to_index(AttributeOwner &owner, const char *name)
bool BKE_attribute_remove(AttributeOwner &owner, const char *name, ReportList *reports)
AttrDomain BKE_attribute_domain(const AttributeOwner &owner, const CustomDataLayer *layer)
std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, const blender::StringRef name)
static void bke_attribute_copy_if_exists(AttributeOwner &owner, const char *srcname, const char *dstname)
CustomDataLayer * BKE_attribute_from_index(AttributeOwner &owner, int lookup_index, AttrDomainMask domain_mask, eCustomDataMask layer_mask)
int * BKE_attributes_active_index_p(AttributeOwner &owner)
const char * BKE_id_attributes_active_color_name(const ID *id)
void BKE_id_attributes_active_color_set(ID *id, const char *name)
bool BKE_attribute_rename(AttributeOwner &owner, const char *old_name, const char *new_name, ReportList *reports)
CustomDataLayer * BKE_attribute_duplicate(AttributeOwner &owner, const char *name, ReportList *reports)
void BKE_id_attributes_active_color_clear(ID *id)
bool BKE_color_attribute_supported(const Mesh &mesh, const blender::StringRef name)
CustomDataLayer * BKE_attribute_search_for_write(AttributeOwner &owner, const char *name, const eCustomDataMask type_mask, const AttrDomainMask domain_mask)
CustomDataLayer * BKE_attribute_find(const AttributeOwner &owner, const char *name, const eCustomDataType type, const AttrDomain domain)
void BKE_id_attributes_default_color_set(ID *id, const char *name)
void BKE_attributes_active_set(AttributeOwner &owner, const char *name)
const char * BKE_uv_map_pin_name_get(const char *uv_map_name, char *buffer)
CustomDataLayer * BKE_attributes_active_get(AttributeOwner &owner)
const CustomDataLayer * BKE_attribute_search(const AttributeOwner &owner, const char *name, const eCustomDataMask type_mask, const AttrDomainMask domain_mask)
static std::array< DomainInfo, ATTR_DOMAIN_NUM > get_domains(const AttributeOwner &owner)
CustomDataLayer * BKE_attribute_new(AttributeOwner &owner, const char *name, const eCustomDataType type, const AttrDomain domain, ReportList *reports)
int BKE_attribute_data_length(AttributeOwner &owner, CustomDataLayer *layer)
int BKE_attributes_length(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask mask)
bool BKE_attribute_required(const AttributeOwner &owner, const char *name)
const char * BKE_uv_map_vert_select_name_get(const char *uv_map_name, char *buffer)
static bool attribute_name_exists(const AttributeOwner &owner, const blender::StringRef name)
static const char * color_name_from_index(AttributeOwner &owner, int index)
const char * BKE_uv_map_edge_select_name_get(const char *uv_map_name, char *buffer)
int BKE_attribute_domain_size(const AttributeOwner &owner, const int domain)
void BKE_attributes_active_clear(AttributeOwner &owner)
bool BM_data_layer_free_named(BMesh *bm, CustomData *data, const char *name)
void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name)
ATTR_WARN_UNUSED_RESULT BMesh * bm
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
AttributeOwnerType type() const
static AttributeOwner from_id(ID *id)
GreasePencil * get_grease_pencil() const
PointCloud * get_pointcloud() const
Curves * get_curves() const
GreasePencilDrawing * get_grease_pencil_drawing() const
const CPPType & type() const
constexpr bool contains_ptr(const T *ptr) const
MutableAttributeAccessor attributes_for_write()
bke::CurvesGeometry & strokes_for_write()
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
bool allow_procedural_attribute_access(StringRef attribute_name)
static std::optional< blender::bke::MutableAttributeAccessor > get_attribute_accessor_for_write(AttributeOwner &owner)
int attributes_active_index
int attributes_active_index
int attributes_active_index
int attributes_active_index