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
This commit is contained in:
Pablo Dobarro 2019-10-08 18:10:02 +02:00
parent a47f694b86
commit a482d940bc
6 changed files with 36 additions and 5 deletions

View File

@ -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()

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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),

View File

@ -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);