Merge branch 'blender-v4.0-release'
This commit is contained in:
commit
5d3ce7c679
|
@ -79,10 +79,15 @@ struct CustomDataLayer *BKE_id_attribute_find(const struct ID *id,
|
||||||
eCustomDataType type,
|
eCustomDataType type,
|
||||||
eAttrDomain domain);
|
eAttrDomain domain);
|
||||||
|
|
||||||
struct CustomDataLayer *BKE_id_attribute_search(struct ID *id,
|
const struct CustomDataLayer *BKE_id_attribute_search(const struct ID *id,
|
||||||
const char *name,
|
const char *name,
|
||||||
eCustomDataMask type,
|
eCustomDataMask type,
|
||||||
eAttrDomainMask domain_mask);
|
eAttrDomainMask domain_mask);
|
||||||
|
|
||||||
|
struct CustomDataLayer *BKE_id_attribute_search_for_write(struct ID *id,
|
||||||
|
const char *name,
|
||||||
|
eCustomDataMask type,
|
||||||
|
eAttrDomainMask domain_mask);
|
||||||
|
|
||||||
eAttrDomain BKE_id_attribute_domain(const struct ID *id, const struct CustomDataLayer *layer);
|
eAttrDomain BKE_id_attribute_domain(const struct ID *id, const struct CustomDataLayer *layer);
|
||||||
int BKE_id_attribute_data_length(struct ID *id, struct CustomDataLayer *layer);
|
int BKE_id_attribute_data_length(struct ID *id, struct CustomDataLayer *layer);
|
||||||
|
|
|
@ -158,7 +158,7 @@ static bool bke_id_attribute_rename_if_exists(ID *id,
|
||||||
const char *new_name,
|
const char *new_name,
|
||||||
ReportList *reports)
|
ReportList *reports)
|
||||||
{
|
{
|
||||||
CustomDataLayer *layer = BKE_id_attribute_search(
|
CustomDataLayer *layer = BKE_id_attribute_search_for_write(
|
||||||
id, old_name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
id, old_name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
||||||
if (layer == nullptr) {
|
if (layer == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -194,7 +194,7 @@ bool BKE_id_attribute_rename(ID *id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomDataLayer *layer = BKE_id_attribute_search(
|
CustomDataLayer *layer = BKE_id_attribute_search_for_write(
|
||||||
id, old_name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
id, old_name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
||||||
if (layer == nullptr) {
|
if (layer == nullptr) {
|
||||||
BKE_report(reports, RPT_ERROR, "Attribute is not part of this geometry");
|
BKE_report(reports, RPT_ERROR, "Attribute is not part of this geometry");
|
||||||
|
@ -383,7 +383,7 @@ CustomDataLayer *BKE_id_attribute_duplicate(ID *id, const char *name, ReportList
|
||||||
BKE_uv_map_pin_name_get(uniquename, buffer_dst));
|
BKE_uv_map_pin_name_get(uniquename, buffer_dst));
|
||||||
}
|
}
|
||||||
|
|
||||||
return BKE_id_attribute_search(id, uniquename, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
return BKE_id_attribute_search_for_write(id, uniquename, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int color_name_to_index(ID *id, const char *name)
|
static int color_name_to_index(ID *id, const char *name)
|
||||||
|
@ -540,10 +540,10 @@ CustomDataLayer *BKE_id_attribute_find(const ID *id,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomDataLayer *BKE_id_attribute_search(ID *id,
|
const CustomDataLayer *BKE_id_attribute_search(const ID *id,
|
||||||
const char *name,
|
const char *name,
|
||||||
const eCustomDataMask type_mask,
|
const eCustomDataMask type_mask,
|
||||||
const eAttrDomainMask domain_mask)
|
const eAttrDomainMask domain_mask)
|
||||||
{
|
{
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -574,6 +574,28 @@ CustomDataLayer *BKE_id_attribute_search(ID *id,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CustomDataLayer *BKE_id_attribute_search_for_write(ID *id,
|
||||||
|
const char *name,
|
||||||
|
const eCustomDataMask type_mask,
|
||||||
|
const eAttrDomainMask domain_mask)
|
||||||
|
{
|
||||||
|
/* Reuse the implementation of the const version.
|
||||||
|
* Implicit sharing for the layer's data is handled below. */
|
||||||
|
CustomDataLayer *layer = const_cast<CustomDataLayer *>(
|
||||||
|
BKE_id_attribute_search(id, name, type_mask, domain_mask));
|
||||||
|
if (!layer) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
DomainInfo info[ATTR_DOMAIN_NUM];
|
||||||
|
get_domains(id, info);
|
||||||
|
|
||||||
|
const eAttrDomain domain = BKE_id_attribute_domain(id, layer);
|
||||||
|
CustomData_ensure_data_is_mutable(layer, info[domain].length);
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomDataMask mask)
|
int BKE_id_attributes_length(const ID *id, eAttrDomainMask domain_mask, eCustomDataMask mask)
|
||||||
{
|
{
|
||||||
DomainInfo info[ATTR_DOMAIN_NUM];
|
DomainInfo info[ATTR_DOMAIN_NUM];
|
||||||
|
|
|
@ -1430,7 +1430,7 @@ static void pbvh_update_BB_redraw(PBVH *pbvh, Span<PBVHNode *> nodes, int flag)
|
||||||
|
|
||||||
bool BKE_pbvh_get_color_layer(Mesh *me, CustomDataLayer **r_layer, eAttrDomain *r_domain)
|
bool BKE_pbvh_get_color_layer(Mesh *me, CustomDataLayer **r_layer, eAttrDomain *r_domain)
|
||||||
{
|
{
|
||||||
*r_layer = BKE_id_attribute_search(
|
*r_layer = BKE_id_attribute_search_for_write(
|
||||||
&me->id, me->active_color_attribute, CD_MASK_COLOR_ALL, ATTR_DOMAIN_MASK_COLOR);
|
&me->id, me->active_color_attribute, CD_MASK_COLOR_ALL, ATTR_DOMAIN_MASK_COLOR);
|
||||||
*r_domain = *r_layer ? BKE_id_attribute_domain(&me->id, *r_layer) : ATTR_DOMAIN_POINT;
|
*r_domain = *r_layer ? BKE_id_attribute_domain(&me->id, *r_layer) : ATTR_DOMAIN_POINT;
|
||||||
return *r_layer != nullptr;
|
return *r_layer != nullptr;
|
||||||
|
|
|
@ -1766,7 +1766,7 @@ static void sculpt_undo_set_active_layer(bContext *C, SculptAttrRef *attr)
|
||||||
* domain and just unconvert it.
|
* domain and just unconvert it.
|
||||||
*/
|
*/
|
||||||
if (!layer) {
|
if (!layer) {
|
||||||
layer = BKE_id_attribute_search(&me->id, attr->name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
layer = BKE_id_attribute_search_for_write(&me->id, attr->name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
|
||||||
if (layer) {
|
if (layer) {
|
||||||
if (ED_geometry_attribute_convert(
|
if (ED_geometry_attribute_convert(
|
||||||
me, attr->name, eCustomDataType(attr->type), attr->domain, nullptr))
|
me, attr->name, eCustomDataType(attr->type), attr->domain, nullptr))
|
||||||
|
|
|
@ -590,10 +590,11 @@ static void rna_AttributeGroup_update_active(Main *bmain, Scene *scene, PointerR
|
||||||
static PointerRNA rna_AttributeGroup_active_color_get(PointerRNA *ptr)
|
static PointerRNA rna_AttributeGroup_active_color_get(PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
ID *id = ptr->owner_id;
|
ID *id = ptr->owner_id;
|
||||||
CustomDataLayer *layer = BKE_id_attribute_search(ptr->owner_id,
|
CustomDataLayer *layer = BKE_id_attribute_search_for_write(
|
||||||
BKE_id_attributes_active_color_name(id),
|
ptr->owner_id,
|
||||||
CD_MASK_COLOR_ALL,
|
BKE_id_attributes_active_color_name(id),
|
||||||
ATTR_DOMAIN_MASK_COLOR);
|
CD_MASK_COLOR_ALL,
|
||||||
|
ATTR_DOMAIN_MASK_COLOR);
|
||||||
|
|
||||||
PointerRNA attribute_ptr = RNA_pointer_create(id, &RNA_Attribute, layer);
|
PointerRNA attribute_ptr = RNA_pointer_create(id, &RNA_Attribute, layer);
|
||||||
return attribute_ptr;
|
return attribute_ptr;
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ DEFINE_CUSTOMDATA_LAYER_COLLECTION(vertex_color, ldata, CD_PROP_BYTE_COLOR)
|
||||||
static PointerRNA rna_Mesh_vertex_color_active_get(PointerRNA *ptr)
|
static PointerRNA rna_Mesh_vertex_color_active_get(PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
Mesh *mesh = (Mesh *)ptr->data;
|
Mesh *mesh = (Mesh *)ptr->data;
|
||||||
CustomDataLayer *layer = BKE_id_attribute_search(
|
CustomDataLayer *layer = BKE_id_attribute_search_for_write(
|
||||||
&mesh->id, mesh->active_color_attribute, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_CORNER);
|
&mesh->id, mesh->active_color_attribute, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_CORNER);
|
||||||
return rna_pointer_inherit_refine(ptr, &RNA_MeshLoopColorLayer, layer);
|
return rna_pointer_inherit_refine(ptr, &RNA_MeshLoopColorLayer, layer);
|
||||||
}
|
}
|
||||||
|
@ -1102,7 +1102,7 @@ static void rna_Mesh_vertex_color_active_set(PointerRNA *ptr,
|
||||||
static int rna_Mesh_vertex_color_active_index_get(PointerRNA *ptr)
|
static int rna_Mesh_vertex_color_active_index_get(PointerRNA *ptr)
|
||||||
{
|
{
|
||||||
Mesh *mesh = (Mesh *)ptr->data;
|
Mesh *mesh = (Mesh *)ptr->data;
|
||||||
CustomDataLayer *layer = BKE_id_attribute_search(
|
const CustomDataLayer *layer = BKE_id_attribute_search(
|
||||||
&mesh->id, mesh->active_color_attribute, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_CORNER);
|
&mesh->id, mesh->active_color_attribute, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_CORNER);
|
||||||
if (!layer) {
|
if (!layer) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue