From cc6ec71b1934b5489caa538c13d290b45d2b1aa5 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Tue, 17 Nov 2020 22:33:09 +0100 Subject: Sculpt: Wet paint area radius This adds a new property to the sculpt vertex color paint brush to limit the area of the brush that is going to be used to sample the wet paint color. This is exactly the same concept as normal radius and area radius that exist for sculpting brushes for sampling the surface depth and orientation. When working near color hard edges, this allows to prevent the color from the other side of the edge to blend into the wet paint. With 1.0 (the previous default) wet paint radius, as soon as the brush touches one vertex of the other color, the wet paint mix color changes, making it impossible to maintain the border between the two colors. Reviewed By: sergey, dbystedt, JulienKaspar Differential Revision: https://developer.blender.org/D9587 --- source/blender/blenkernel/intern/brush.c | 1 + source/blender/blenloader/intern/versioning_290.c | 7 +++++++ source/blender/editors/sculpt_paint/sculpt_paint_color.c | 3 +++ source/blender/makesdna/DNA_brush_defaults.h | 1 + source/blender/makesdna/DNA_brush_types.h | 3 ++- source/blender/makesrna/intern/rna_brush.c | 10 ++++++++++ 6 files changed, 24 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 1b77989c2b8..96791aed2c3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -446,6 +446,7 @@ static void brush_defaults(Brush *brush) FROM_DEFAULT(topology_rake_factor); FROM_DEFAULT(crease_pinch_factor); FROM_DEFAULT(normal_radius_factor); + FROM_DEFAULT(wet_paint_radius_factor); FROM_DEFAULT(area_radius_factor); FROM_DEFAULT(disconnected_distance_max); FROM_DEFAULT(sculpt_plane); diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 9278ff51b8d..cebeef1fc46 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -483,6 +483,13 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) } } } + + /* Wet Paint Radius Factor */ + for (Brush *br = bmain->brushes.first; br; br = br->id.next) { + if (br->ob_mode & OB_MODE_SCULPT && br->wet_paint_radius_factor == 0.0f) { + br->wet_paint_radius_factor = 1.0f; + } + } } static void panels_remove_x_closed_flag_recursive(Panel *panel) diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index f0047448a8d..39320f3f558 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -220,6 +220,9 @@ static void do_sample_wet_paint_task_cb(void *__restrict userdata, SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( ss, &test, data->brush->falloff_shape); + test.radius *= data->brush->wet_paint_radius_factor; + test.radius_squared = test.radius * test.radius; + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { if (sculpt_brush_test_sq_fn(&test, vd.co)) { diff --git a/source/blender/makesdna/DNA_brush_defaults.h b/source/blender/makesdna/DNA_brush_defaults.h index b0a35ac783e..fb726e24929 100644 --- a/source/blender/makesdna/DNA_brush_defaults.h +++ b/source/blender/makesdna/DNA_brush_defaults.h @@ -45,6 +45,7 @@ .topology_rake_factor = 0.0f, \ .crease_pinch_factor = 0.5f, \ .normal_radius_factor = 0.5f, \ + .wet_paint_radius_factor = 0.5f, \ .area_radius_factor = 0.5f, \ .disconnected_distance_max = 0.1f, \ .sculpt_plane = SCULPT_DISP_DIR_AREA, \ diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 756f21321f4..50aac69da19 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -573,7 +573,7 @@ typedef struct Brush { char gpencil_sculpt_tool; /** Active grease pencil weight tool. */ char gpencil_weight_tool; - char _pad1[6]; + char _pad1[2]; float autosmooth_factor; @@ -585,6 +585,7 @@ typedef struct Brush { float normal_radius_factor; float area_radius_factor; + float wet_paint_radius_factor; float plane_trim; /** Affectable height of brush (layer height for layer tool, i.e.). */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 1e5309e5869..cf36c1a3742 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -2854,6 +2854,16 @@ static void rna_def_brush(BlenderRNA *brna) "used to sample the area center"); RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "wet_paint_radius_factor", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "wet_paint_radius_factor"); + RNA_def_property_range(prop, 0.0f, 2.0f); + RNA_def_property_ui_range(prop, 0.0f, 2.0f, 0.001, 3); + RNA_def_property_ui_text(prop, + "Wet Paint Radius", + "Ratio between the brush radius and the radius that is going to be " + "used to sample the color to blend in wet paint"); + RNA_def_property_update(prop, 0, "rna_Brush_update"); + prop = RNA_def_property(srna, "stencil_pos", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "stencil_pos"); RNA_def_property_array(prop, 2); -- cgit v1.2.3