[Bf-blender-cvs] [7753fda1b56] sculpt-dev: Sculpt-dev: fix broken vcol attr auto-creation
Joseph Eagar
noreply at git.blender.org
Sat Nov 20 16:51:08 CET 2021
Commit: 7753fda1b56ae6f2b6040368efa44f506e01c11b
Author: Joseph Eagar
Date: Sat Nov 20 07:49:40 2021 -0800
Branches: sculpt-dev
https://developer.blender.org/rB7753fda1b56ae6f2b6040368efa44f506e01c11b
Sculpt-dev: fix broken vcol attr
auto-creation
* Fixed BKE_sculpt_color_layer_create_if_needed
* Also fixed BKE_id_attribute_active_color_set,
accidentally pasted the getter's precondition.
===================================================================
M source/blender/blenkernel/intern/attribute.c
M source/blender/blenkernel/intern/paint.c
===================================================================
diff --git a/source/blender/blenkernel/intern/attribute.c b/source/blender/blenkernel/intern/attribute.c
index 20142fd4f2e..d13f3c4e277 100644
--- a/source/blender/blenkernel/intern/attribute.c
+++ b/source/blender/blenkernel/intern/attribute.c
@@ -476,6 +476,11 @@ CustomDataLayer *BKE_id_attributes_active_color_get(ID *id)
return NULL;
}
+ if (!ref->type) {
+ fprintf(stderr, "%s: invalid active color attribute\n", __func__);
+ return NULL;
+ }
+
DomainInfo info[ATTR_DOMAIN_NUM];
get_domains(id, info);
@@ -490,8 +495,6 @@ void BKE_id_attributes_active_color_set(ID *id, CustomDataLayer *active_layer)
if (!ref) {
fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
- }
- if (!ref || !ref->type) {
return;
}
@@ -541,8 +544,11 @@ CustomDataLayer *BKE_id_attributes_render_color_get(ID *id)
if (!ref) {
fprintf(stderr, "%s: vertex colors not supported for this type\n", __func__);
+ return NULL;
}
- if (!ref || !ref->type) {
+
+ if (!ref->type) {
+ fprintf(stderr, "%s: invalid render color attribute\n", __func__);
return NULL;
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index ce8dc3fa566..b8f87818a70 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -2047,7 +2047,7 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
CustomDataLayer *cl;
if (has_color) {
- cl = BKE_id_attributes_active_get(&orig_me->id);
+ cl = BKE_id_attributes_active_color_get(&orig_me->id);
if (!cl || !ELEM(cl->type, CD_PROP_COLOR, CD_MLOOPCOL)) {
cl = NULL;
@@ -2072,13 +2072,18 @@ void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
CustomData_add_layer(&orig_me->vdata, CD_PROP_COLOR, CD_DEFAULT, NULL, orig_me->totvert);
cl = orig_me->vdata.layers + CustomData_get_layer_index(&orig_me->vdata, CD_PROP_COLOR);
+ BKE_id_attributes_render_color_set(&orig_me->id, cl);
+ BKE_id_attributes_active_color_set(&orig_me->id, cl);
+
BKE_mesh_update_customdata_pointers(orig_me, true);
+ DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES);
}
-
+
if (cl) {
- BKE_id_attributes_active_set(&orig_me->id, cl);
- DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES);
+ BKE_id_attributes_active_color_set(&orig_me->id, cl);
}
+
+ BKE_sculptsession_sync_attributes(object, orig_me);
}
void BKE_sculpt_update_object_for_edit(
@@ -2750,7 +2755,11 @@ void BKE_sculptsession_sync_attributes(struct Object *ob, struct Mesh *me)
{
SculptSession *ss = ob->sculpt;
- if (!ss || !ss->bm) {
+ if (!ss) {
+ return;
+ }
+ else if (!ss->bm) {
+ BKE_sculptsession_update_attr_refs(ob);
return;
}
@@ -3307,14 +3316,22 @@ void BKE_sculptsession_update_attr_refs(Object *ob)
BKE_pbvh_get_color_layer(ss->pbvh, me, &layer, &domain);
- ss->vcol_domain = domain;
- ss->vcol_type = layer->type;
-
- if (ss->bm) {
- ss->cd_vcol_offset = layer->offset;
+ if (!layer) {
+ ss->vcol_domain = ATTR_DOMAIN_NUM;
+ ss->vcol_type = -1;
+ ss->cd_vcol_offset = -1;
+ ss->vcol = NULL;
}
else {
- ss->vcol = layer->data;
+ ss->vcol_domain = domain;
+ ss->vcol_type = layer->type;
+
+ if (ss->bm) {
+ ss->cd_vcol_offset = layer->offset;
+ }
+ else {
+ ss->vcol = layer->data;
+ }
}
}
More information about the Bf-blender-cvs
mailing list