[Bf-blender-cvs] [a482d940bc1] master: Sculpt: Invert Scrape to Fill

Pablo Dobarro noreply at git.blender.org
Thu Nov 21 19:04:09 CET 2019


Commit: a482d940bc16d02e03ac6adf0d24c281ca99a2fa
Author: Pablo Dobarro
Date:   Tue Oct 8 18:10:02 2019 +0200
Branches: master
https://developer.blender.org/rBa482d940bc16d02e03ac6adf0d24c281ca99a2fa

Sculpt: Invert Scrape to Fill

After adding normal radius, the main use of the Scrape brush is to create flat surfaces with sharp edges. In that case, it does not make sense to have our current "Peaks" version of the brush as its inverted version.
The correct inverted version of Scrape for this use case is the Fill brush. This way you can use this tool to crease both concave and convex sharp edges and to fix the artifacts one version produces with its inverted version.
I think we should merge these two tools into one, but for now, this solution keeps compatibility with the old behavior.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6022

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 2f260b59c4f..724264fe494 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -428,6 +428,12 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
                 row.prop(brush, "pose_offset")
                 row = col.row()
                 row.prop(brush, "pose_smooth_iterations")
+            elif brush.sculpt_tool == 'SCRAPE':
+                row = col.row()
+                row.prop(brush, "invert_to_scrape_fill", text = "Invert to Fill")
+            elif brush.sculpt_tool == 'FILL':
+                row = col.row()
+                row.prop(brush, "invert_to_scrape_fill", text = "Invert to Scrape")
             elif brush.sculpt_tool == 'GRAB':
                 col.separator()
                 row = col.row()
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 8d256132aa4..8ba1aa20a26 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -955,9 +955,11 @@ void BKE_brush_sculpt_reset(Brush *br)
       br->alpha = 0.25;
       break;
     case SCULPT_TOOL_SCRAPE:
+    case SCULPT_TOOL_FILL:
       br->alpha = 1.0f;
       br->spacing = 7;
       br->flag |= BRUSH_ACCUMULATE;
+      br->flag |= BRUSH_INVERT_TO_SCRAPE_FILL;
       break;
     case SCULPT_TOOL_ROTATE:
       br->alpha = 1.0;
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index a3dc177262e..8a8a5ade476 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1747,8 +1747,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
       for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
         br->falloff_angle = DEG2RADF(80);
         /* These flags are used for new feautres. They are not related to falloff_angle */
-        br->flag &= ~(BRUSH_FLAG_UNUSED_1 | BRUSH_ORIGINAL_PLANE | BRUSH_GRAB_ACTIVE_VERTEX |
-                      BRUSH_SCENE_SPACING | BRUSH_FRONTFACE_FALLOFF);
+        br->flag &= ~(BRUSH_INVERT_TO_SCRAPE_FILL | BRUSH_ORIGINAL_PLANE |
+                      BRUSH_GRAB_ACTIVE_VERTEX | BRUSH_SCENE_SPACING | BRUSH_FRONTFACE_FALLOFF);
       }
 
       for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c30986a4d4b..ff559acf361 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -1731,6 +1731,9 @@ static float brush_strength(const Sculpt *sd,
    * normalized diameter */
 
   float flip = dir * invert * pen_flip;
+  if (brush->flag & BRUSH_INVERT_TO_SCRAPE_FILL) {
+    flip = 1.0f;
+  }
 
   /* Pressure final value after being tweaked depending on the brush */
   float final_pressure;
@@ -5945,6 +5948,8 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
       sculpt_pose_brush_init(sd, ob, ss, brush, ss->cache->location, ss->cache->radius);
     }
 
+    bool invert = ss->cache->pen_flip || ss->cache->invert || brush->flag & BRUSH_DIR_IN;
+
     /* Apply one type of brush action */
     switch (brush->sculpt_tool) {
       case SCULPT_TOOL_DRAW:
@@ -5996,10 +6001,20 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe
         do_multiplane_scrape_brush(sd, ob, nodes, totnode);
         break;
       case SCULPT_TOOL_FILL:
-        do_fill_brush(sd, ob, nodes, totnode);
+        if (invert && brush->flag & BRUSH_INVERT_TO_SCRAPE_FILL) {
+          do_scrape_brush(sd, ob, nodes, totnode);
+        }
+        else {
+          do_fill_brush(sd, ob, nodes, totnode);
+        }
         break;
       case SCULPT_TOOL_SCRAPE:
-        do_scrape_brush(sd, ob, nodes, totnode);
+        if (invert && brush->flag & BRUSH_INVERT_TO_SCRAPE_FILL) {
+          do_fill_brush(sd, ob, nodes, totnode);
+        }
+        else {
+          do_scrape_brush(sd, ob, nodes, totnode);
+        }
         break;
       case SCULPT_TOOL_MASK:
         do_mask_brush(sd, ob, nodes, totnode);
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 8c502941438..8f9bc1ddedb 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -416,7 +416,7 @@ typedef enum eBrushGradientSourceFill {
 /* Brush.flag */
 typedef enum eBrushFlags {
   BRUSH_AIRBRUSH = (1 << 0),
-  BRUSH_FLAG_UNUSED_1 = (1 << 1), /* cleared */
+  BRUSH_INVERT_TO_SCRAPE_FILL = (1 << 1),
   BRUSH_ALPHA_PRESSURE = (1 << 2),
   BRUSH_SIZE_PRESSURE = (1 << 3),
   BRUSH_JITTER_PRESSURE = (1 << 4),
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 8bc6b252d30..cd641c3d372 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -2060,6 +2060,14 @@ static void rna_def_brush(BlenderRNA *brna)
       prop, "Show Cursor Preview", "Preview the scrape planes in the cursor during the stroke");
   RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+  prop = RNA_def_property(srna, "invert_to_scrape_fill", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_INVERT_TO_SCRAPE_FILL);
+  RNA_def_property_ui_text(prop,
+                           "Invert to Scrape or Fill",
+                           "Use Scrape or Fill tool when inverting this brush instead of "
+                           "inverting its displacement direction");
+  RNA_def_property_update(prop, 0, "rna_Brush_update");
+
   prop = RNA_def_property(srna, "use_pressure_strength", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE);
   RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);



More information about the Bf-blender-cvs mailing list