Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/attribute.cc
| Show First 20 Lines • Show All 359 Lines • ▼ Show 20 Lines | if (customdata && | ||||
| return static_cast<eAttrDomain>(domain); | return static_cast<eAttrDomain>(domain); | ||||
| } | } | ||||
| } | } | ||||
| BLI_assert_msg(0, "Custom data layer not found in geometry"); | BLI_assert_msg(0, "Custom data layer not found in geometry"); | ||||
| return static_cast<eAttrDomain>(ATTR_DOMAIN_POINT); | return static_cast<eAttrDomain>(ATTR_DOMAIN_POINT); | ||||
| } | } | ||||
| int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer) | int BKE_id_attribute_data_length(const ID *id, CustomDataLayer *layer) | ||||
| { | { | ||||
| /* When in mesh editmode, attributes point to bmesh customdata layers, the attribute data is | /* When in mesh editmode, attributes point to bmesh customdata layers, the attribute data is | ||||
| * empty since custom data is stored per element instead of a single array there (same es UVs | * empty since custom data is stored per element instead of a single array there (same es UVs | ||||
| * etc.), see D11998. */ | * etc.), see D11998. */ | ||||
| switch (GS(id->name)) { | switch (GS(id->name)) { | ||||
| case ID_ME: { | case ID_ME: { | ||||
| Mesh *mesh = (Mesh *)id; | const Mesh *mesh = (const Mesh *)id; | ||||
| if (mesh->edit_mesh != nullptr) { | if (mesh->edit_mesh != nullptr) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| DomainInfo info[ATTR_DOMAIN_NUM]; | DomainInfo info[ATTR_DOMAIN_NUM]; | ||||
| get_domains(id, info); | get_domains(id, info); | ||||
| for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) { | for (const int domain : IndexRange(ATTR_DOMAIN_NUM)) { | ||||
| CustomData *customdata = info[domain].customdata; | CustomData *customdata = info[domain].customdata; | ||||
| if (customdata && | if (customdata && | ||||
| ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) { | ARRAY_HAS_ITEM((CustomDataLayer *)layer, customdata->layers, customdata->totlayer)) { | ||||
| return info[domain].length; | return info[domain].length; | ||||
| } | } | ||||
| } | } | ||||
| BLI_assert_msg(0, "Custom data layer not found in geometry"); | BLI_assert_msg(0, "Custom data layer not found in geometry"); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| int BKE_id_attribute_domain_length(const ID *id, eAttrDomain domain) | |||||
| { | |||||
| DomainInfo info[ATTR_DOMAIN_NUM]; | |||||
| get_domains(id, info); | |||||
| return info[domain].length; | |||||
| } | |||||
| bool BKE_id_attribute_required(const ID *id, const char *name) | bool BKE_id_attribute_required(const ID *id, const char *name) | ||||
| { | { | ||||
| switch (GS(id->name)) { | switch (GS(id->name)) { | ||||
| case ID_PT: { | case ID_PT: { | ||||
| return BKE_pointcloud_customdata_required((const PointCloud *)id, name); | return BKE_pointcloud_customdata_required((const PointCloud *)id, name); | ||||
| } | } | ||||
| case ID_CV: { | case ID_CV: { | ||||
| return BKE_curves_customdata_required((const Curves *)id, name); | return BKE_curves_customdata_required((const Curves *)id, name); | ||||
| ▲ Show 20 Lines • Show All 346 Lines • Show Last 20 Lines | |||||