[Bf-blender-cvs] [cc6ec71b193] master: Sculpt: Wet paint area radius

Pablo Dobarro noreply at git.blender.org
Thu Dec 3 22:55:51 CET 2020


Commit: cc6ec71b1934b5489caa538c13d290b45d2b1aa5
Author: Pablo Dobarro
Date:   Tue Nov 17 22:33:09 2020 +0100
Branches: master
https://developer.blender.org/rBcc6ec71b1934b5489caa538c13d290b45d2b1aa5

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

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/editors/sculpt_paint/sculpt_paint_color.c
M	source/blender/makesdna/DNA_brush_defaults.h
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 63ccbd2ae05..3075d76d6fa 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -716,6 +716,9 @@ def brush_settings(layout, context, brush, popover=False):
             row.prop(brush, "invert_wet_persistence_pressure", text="")
             row.prop(brush, "use_wet_persistence_pressure", text="")
 
+            row = layout.row(align=True)
+            row.prop(brush, "wet_paint_radius_factor")
+
             row = layout.row(align=True)
             row.prop(brush, "density")
             row.prop(brush, "invert_density_pressure", text="")
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);



More information about the Bf-blender-cvs mailing list