[Bf-blender-cvs] [4a90199e22e] temp-sculpt-colors: Merge branch 'master' into temp-sculpt-colors

Joseph Eagar noreply at git.blender.org
Tue Jan 4 13:12:40 CET 2022


Commit: 4a90199e22e23daa891256181b1e97552f74fc9d
Author: Joseph Eagar
Date:   Tue Jan 4 04:12:28 2022 -0800
Branches: temp-sculpt-colors
https://developer.blender.org/rB4a90199e22e23daa891256181b1e97552f74fc9d

Merge branch 'master' into temp-sculpt-colors

===================================================================



===================================================================

diff --cc release/scripts/addons
index f6107e2fd9a,c08568cc376..c60fef38175
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit f6107e2fd9a92b55ac110c7db941e287e2f6604a
 -Subproject commit c08568cc376d2e4298710c4172fb0c74f0611de1
++Subproject commit c60fef38175ad989ee0c45e924cb27e1417c8667
diff --cc source/blender/blenkernel/BKE_attribute.h
index f3614e31313,1e2dcf09b64..68d5c7948a3
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@@ -100,34 -83,7 +97,39 @@@ void BKE_id_attributes_active_set(struc
  int *BKE_id_attributes_active_index_p(struct ID *id);
  
  CustomData *BKE_id_attributes_iterator_next_domain(struct ID *id, struct CustomDataLayer *layers);
 +CustomDataLayer *BKE_id_attribute_from_index(const struct ID *id,
 +                                             int lookup_index,
 +                                             const AttributeDomainMask domain_mask);
 +
 +struct AttributeRef *BKE_id_attributes_active_color_ref_p(struct ID *id);
 +void BKE_id_attributes_active_color_set(struct ID *id, struct CustomDataLayer *active_layer);
 +struct CustomDataLayer *BKE_id_attributes_active_color_get(struct ID *id);
 +
 +struct AttributeRef *BKE_id_attributes_render_color_ref_p(struct ID *id);
 +void BKE_id_attributes_render_color_set(struct ID *id, struct CustomDataLayer *active_layer);
 +CustomDataLayer *BKE_id_attributes_render_color_get(struct ID *id);
 +
 +bool BKE_id_attribute_find_unique_name(struct ID *id,
 +                                       const char *name,
 +                                       char *outname,
 +                                       CustomDataMask mask);
 +
 +int BKE_id_attribute_index_from_ref(struct ID *id,
 +                                    struct AttributeRef *ref,
 +                                    AttributeDomainMask domain_mask,
 +                                    CustomDataMask type_filter);
 +
 +bool BKE_id_attribute_ref_from_index(struct ID *id,
 +                                     int attr_index,
 +                                     AttributeDomainMask domain_mask,
 +                                     CustomDataMask type_filter,
 +                                     struct AttributeRef *r_ref);
 +
++bool BKE_id_attribute_ref_layer_equals(const struct AttributeRef *ref,
++                                       const struct CustomDataLayer *layer,
++                                       const AttributeDomain domain);
++bool BKE_id_attribute_ref_equals(const struct AttributeRef *ref1, const struct AttributeRef *ref2);
+ 
  #ifdef __cplusplus
  }
  #endif
diff --cc source/blender/blenkernel/intern/attribute.c
index f5f3803e362,ee8ef5e97f7..67aff869751
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@@ -456,235 -401,3 +456,254 @@@ CustomData *BKE_id_attributes_iterator_
  
    return NULL;
  }
 +
 +CustomDataLayer *BKE_id_attribute_from_index(const ID *id,
 +                                             int lookup_index,
 +                                             const AttributeDomainMask domain_mask)
 +{
 +  DomainInfo info[ATTR_DOMAIN_NUM];
 +  get_domains(id, info);
 +
 +  int index = 0;
 +  for (AttributeDomain domain = 0; domain < ATTR_DOMAIN_NUM; domain++) {
 +    CustomData *customdata = info[domain].customdata;
 +
 +    if (!customdata || !((1 << (int)domain) & domain_mask)) {
 +      continue;
 +    }
 +
 +    for (int i = 0; i < customdata->totlayer; i++) {
 +      if (CD_MASK_PROP_ALL & CD_TYPE_AS_MASK(customdata->layers[i].type)) {
 +        if (index == lookup_index) {
 +          return customdata->layers + i;
 +        }
 +
 +        index++;
 +      }
 +    }
 +  }
 +
 +  return NULL;
 +}
 +
 +CustomDataLayer *BKE_id_attributes_active_color_get(ID *id)
 +{
 +  AttributeRef *ref = BKE_id_attributes_active_color_ref_p(id);
 +
 +  if (!ref) {
 +    fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
 +    return NULL;
 +  }
 +
 +  DomainInfo info[ATTR_DOMAIN_NUM];
 +  get_domains(id, info);
 +
 +  int idx = CustomData_get_named_layer_index(info[ref->domain].customdata, ref->type, ref->name);
 +
 +  return idx != -1 ? info[ref->domain].customdata->layers + idx : NULL;
 +}
 +
 +void BKE_id_attributes_active_color_set(ID *id, CustomDataLayer *active_layer)
 +{
 +  AttributeRef *ref = BKE_id_attributes_active_color_ref_p(id);
 +
 +  if (!ref) {
 +    fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
 +    return;
 +  }
 +
 +  DomainInfo info[ATTR_DOMAIN_NUM];
 +  get_domains(id, info);
 +
 +  if (!active_layer || !ELEM(active_layer->type, CD_PROP_COLOR, CD_MLOOPCOL)) {
 +    fprintf(stderr,
 +            "bad active color layer %p; type was %d\n",
 +            active_layer,
 +            active_layer ? active_layer->type : -1);
 +    return;
 +  }
 +
 +  for (AttributeDomain domain = 0; domain < ATTR_DOMAIN_NUM; domain++) {
 +    CustomData *customdata = info[domain].customdata;
 +
 +    if (customdata) {
 +      for (int i = 0; i < customdata->totlayer; i++) {
 +        CustomDataLayer *layer = &customdata->layers[i];
 +
 +        if (layer == active_layer && ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) {
 +          ref->type = layer->type;
 +          ref->domain = domain;
 +          BLI_strncpy_utf8(ref->name, layer->name, MAX_CUSTOMDATA_LAYER_NAME);
 +          return;
 +        }
 +      }
 +    }
 +  }
 +}
 +
 +AttributeRef *BKE_id_attributes_active_color_ref_p(ID *id)
 +{
 +  switch (GS(id->name)) {
 +    case ID_ME: {
 +      return &((Mesh *)id)->attr_color_active;
 +    }
 +    default:
 +      return NULL;
 +  }
 +}
 +
 +CustomDataLayer *BKE_id_attributes_render_color_get(ID *id)
 +{
 +  AttributeRef *ref = BKE_id_attributes_render_color_ref_p(id);
 +
 +  if (!ref) {
 +    fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
 +    return NULL;
 +  }
 +
 +  DomainInfo info[ATTR_DOMAIN_NUM];
 +  get_domains(id, info);
 +
 +  int idx = CustomData_get_named_layer_index(info[ref->domain].customdata, ref->type, ref->name);
 +
 +  return idx != -1 ? info[ref->domain].customdata->layers + idx : NULL;
 +}
 +
 +void BKE_id_attributes_render_color_set(ID *id, CustomDataLayer *active_layer)
 +{
 +  AttributeRef *ref = BKE_id_attributes_render_color_ref_p(id);
 +
 +  if (!ref) {
 +    fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
 +    return;
 +  }
 +
 +  DomainInfo info[ATTR_DOMAIN_NUM];
 +  get_domains(id, info);
 +
 +  if (!active_layer || !ELEM(active_layer->type, CD_PROP_COLOR, CD_MLOOPCOL)) {
 +    fprintf(stderr,
 +            "bad active color layer %p; type was %d\n",
 +            active_layer,
 +            active_layer ? active_layer->type : -1);
 +    return;
 +  }
 +
 +  for (AttributeDomain domain = 0; domain < ATTR_DOMAIN_NUM; domain++) {
 +    CustomData *customdata = info[domain].customdata;
 +
 +    if (customdata) {
 +      for (int i = 0; i < customdata->totlayer; i++) {
 +        CustomDataLayer *layer = &customdata->layers[i];
 +
 +        if (layer == active_layer && ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) {
 +          ref->type = layer->type;
 +          ref->domain = domain;
 +          BLI_strncpy_utf8(ref->name, layer->name, MAX_CUSTOMDATA_LAYER_NAME);
 +          return;
 +        }
 +      }
 +    }
 +  }
 +}
 +
 +int BKE_id_attribute_index_from_ref(ID *id,
 +                                    AttributeRef *ref,
 +                                    AttributeDomainMask domain_mask,
 +                                    CustomDataMask type_filter)
 +{
 +  DomainInfo info[ATTR_DOMAIN_NUM];
 +  get_domains(id, info);
 +
 +  int index = 0;
 +
 +  for (AttributeDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; domain++) {
 +    CustomData *data = info[domain].customdata;
 +
 +    if (!((1 << (int)domain) & domain_mask) || !data) {
 +      continue;
 +    }
 +
 +    for (int i = 0; i < data->totlayer; i++) {
 +      CustomDataLayer *layer = data->layers + i;
 +
 +      if (layer->type == ref->type && STREQ(layer->name, ref->name)) {
 +        return index;
 +      }
 +
 +      if (CD_TYPE_AS_MASK(layer->type) & type_filter) {
 +        index++;
 +      }
 +    }
 +  }
 +
 +  return -1;
 +}
 +
 +bool BKE_id_attribute_ref_from_index(ID *id,
 +                                     int attr_index,
 +                                     AttributeDomainMask domain_mask,
 +                                     CustomDataMask type_filter,
 +                                     AttributeRef *r_ref)
 +{
 +  DomainInfo info[ATTR_DOMAIN_NUM];
 +  get_domains(id, info);
 +
 +  int index = 0;
 +
 +  for (AttributeDomain domain = ATTR_DOMAIN_POINT; domain < ATTR_DOMAIN_NUM; domain++) {
 +    CustomData *data = info[domain].customdata;
 +
 +    if (!data || !((1 << (int)domain) & domain_mask)) {
 +      continue;
 +    }
 +
 +    for (int i = 0; i < data->totlayer; i++) {
 +      CustomDataLayer *layer = data->layers + i;
 +
 +      if (CD_TYPE_AS_MASK(layer->type) & type_filter) {
 +        if (index == attr_index) {
 +          r_ref->domain = domain;
 +          r_ref->type = layer->type;
 +          BLI_strncpy_utf8(r_ref->name, layer->name, MAX_CUSTOMDATA_LAYER_NAME);
 +
 +          return true;
 +        }
 +
 +        index++;
 +      }
 +    }
 +  }
 +
 +  return false;
 +}
 +
 +AttributeRef *BKE_id_attributes_render_color_ref_p(ID *id)
 +{
 +  switch (GS(id->name)) {
 +    case ID_ME: {
 +      return &((Mesh *)id)->attr_color_render;
 +    }
 +    default:
 +      return NULL;
 +  }
 +}
++
++bool BKE_id_attribute_ref_layer_equals(const struct AttributeRef *ref,
++                                       const struct CustomDataLayer *layer,
++                                       const AttributeDomain domain)
++{
++  bool ok = ref->domain == domain;
++  ok = ok && ref->type == layer->type;
++  ok = ok && STREQ(ref->name, layer->name);
++
++  return ok;
++}
++
++bool BKE_id_attribute_ref_equals(const struct AttributeRef *ref1, const struct AttributeRef *ref2)
++{
++  bool ok = ref1->type == ref2->type && ref1->domain == ref2->domain;
++
++  return ok && STREQ(ref1->name

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list