[Bf-blender-cvs] [fa40124d2e2] temp-sculpt-colors: temp-sculpt-colors: Automatically switch to vertex shading mode when using paint brushes.
Joseph Eagar
noreply at git.blender.org
Wed Jan 5 13:46:43 CET 2022
Commit: fa40124d2e2538f004eea5ab4283f0e4af9d601d
Author: Joseph Eagar
Date: Wed Jan 5 04:45:46 2022 -0800
Branches: temp-sculpt-colors
https://developer.blender.org/rBfa40124d2e2538f004eea5ab4283f0e4af9d601d
temp-sculpt-colors: Automatically switch to vertex
shading mode when using paint
brushes.
Also fixed vcol layer auto-creation failing to
set active color reference properlty.
===================================================================
M source/blender/blenkernel/intern/paint.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
===================================================================
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 82c3c366249..03c54dce915 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1815,39 +1815,18 @@ 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);
- if (!ELEM(cl->type, CD_PROP_COLOR, CD_MLOOPCOL)) {
- cl = NULL;
-
- /* find a color layer */
- for (int step = 0; !cl && step < 2; step++) {
- CustomData *cdata = step ? &orig_me->ldata : &orig_me->vdata;
-
- for (int i = 0; i < cdata->totlayer; i++) {
- if (ELEM(cdata->layers[i].type, CD_PROP_COLOR, CD_MLOOPCOL)) {
- cl = cdata->layers + i;
- break;
- }
- }
- }
- }
- else {
- cl = NULL; /* no need to update active layer */
- }
+ return;
}
- else {
- 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_mesh_update_customdata_pointers(orig_me, true);
- }
+ CustomData_add_layer(&orig_me->vdata, CD_PROP_COLOR, CD_DEFAULT, NULL, orig_me->totvert);
+ CustomDataLayer *cl = orig_me->vdata.layers +
+ CustomData_get_layer_index(&orig_me->vdata, CD_PROP_COLOR);
- if (cl) {
- BKE_id_attributes_active_set(&orig_me->id, cl);
- DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES);
- }
+ BKE_mesh_update_customdata_pointers(orig_me, true);
+
+ BKE_id_attributes_active_color_set(&orig_me->id, cl);
+ DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES);
}
void BKE_sculpt_update_object_for_edit(
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c7af58e5981..a90e33aa107 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5052,7 +5052,7 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op)
sculpt_brush_init_tex(scene, sd, ss);
is_smooth = sculpt_needs_connectivity_info(sd, brush, ss, mode);
- needs_colors = ELEM(brush->sculpt_tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR);
+ needs_colors = SCULPT_TOOL_NEEDS_COLOR(brush->sculpt_tool);
if (needs_colors) {
BKE_sculpt_color_layer_create_if_needed(ob);
@@ -5260,6 +5260,14 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
Object *ob = CTX_data_active_object(C);
SculptSession *ss = ob->sculpt;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
+ Brush *brush = BKE_paint_brush(&sd->paint);
+
+ if (brush && SCULPT_TOOL_NEEDS_COLOR(brush->sculpt_tool)) {
+ View3D *v3d = CTX_wm_view3d(C);
+ if (v3d) {
+ v3d->shading.color_type = V3D_SHADING_VERTEX_COLOR;
+ }
+ }
ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C));
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 57a98d19640..dabed4b8992 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1626,3 +1626,5 @@ void SCULPT_bmesh_topology_rake(struct Sculpt *sd,
void SCULPT_OT_brush_stroke(struct wmOperatorType *ot);
/* end sculpt_ops.c */
+
+#define SCULPT_TOOL_NEEDS_COLOR(tool) ELEM(tool, SCULPT_TOOL_PAINT, SCULPT_TOOL_SMEAR)
More information about the Bf-blender-cvs
mailing list