[Bf-blender-cvs] [68683f2d4a4] greasepencil-object: Add new Eraser modes to UI panel

Antonio Vazquez noreply at git.blender.org
Fri Mar 2 23:38:37 CET 2018


Commit: 68683f2d4a4714f0c517e68a74c3bc9c02482dfd
Author: Antonio Vazquez
Date:   Fri Mar 2 23:19:40 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB68683f2d4a4714f0c517e68a74c3bc9c02482dfd

Add new Eraser modes to UI panel

Now there are 3 types of Eraser in UI panel:

Soft: Need several passes to clean stroke.
Hard: One pass, clean points.
Stroke: Clean all stroke when touch any point.

This modes were available before using modifier keys, but it was not easy to discover.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 775d2a7ccb1..54bb5261f55 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2124,8 +2124,9 @@ class VIEW3D_PT_tools_grease_pencil_brush(Panel):
             if brush.type == 'ERASE':
                 col = layout.column(align=True)
                 col.prop(brush, "line_width", text="Radius")
-                # col.prop(context.user_preferences.edit, "grease_pencil_eraser_radius", text="Radius")
-                # TODO: Hard/Soft mode, sensitivity factors, etc.
+                col.separator()
+                row = col.row()
+                row.prop(brush, "eraser_mode", expand=True)
 
             if brush.type != 'ERASE':
                 layout.separator()
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index d1232fce3a3..91a9d362e5e 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1171,6 +1171,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
                                       const int radius, const rcti *rect)
 {
 	Object *obact = (Object *)p->ownerPtr.data;
+	bGPDbrush *brush = p->brush;
 	bGPDspoint *pt1, *pt2;
 	int pc1[2] = {0};
 	int pc2[2] = {0};
@@ -1200,7 +1201,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
 			}
 		}
 	}
-	else if (p->flags & GP_PAINTFLAG_STROKE_ERASER) {
+	else if ((p->flags & GP_PAINTFLAG_STROKE_ERASER) || (brush->eraser_mode == GP_BRUSH_ERASER_STROKE)) {
 		for (i = 0; (i + 1) < gps->totpoints; i++) {
 
 			/* only process if it hasn't been masked out... */
@@ -1290,11 +1291,11 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
 						pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength / 2.0f;
 						
 						/* 2) Tag any point with overly low influence for removal in the next pass */
-						if ((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER)) {
+						if ((pt1->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || (brush->eraser_mode == GP_BRUSH_ERASER_HARD)) {
 							pt1->flag |= GP_SPOINT_TAG;
 							do_cull = true;
 						}
-						if ((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER)) {
+						if ((pt2->pressure < cull_thresh) || (p->flags & GP_PAINTFLAG_HARD_ERASER) || (brush->eraser_mode == GP_BRUSH_ERASER_HARD)) {
 							pt2->flag |= GP_SPOINT_TAG;
 							do_cull = true;
 						}
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index ed6ff4be7c7..702f6051d3e 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -140,6 +140,8 @@ typedef struct bGPDbrush {
 	float uv_random;          /* random factor for UV rotation */
 	int   input_samples;      /* maximum distance before generate new point for very fast mouse movements */
 	int   type;               /* type of brush (draw, fill, erase, etc..) */
+	int   eraser_mode;        /* soft, hard or stroke */
+	char  pad[4];
 } bGPDbrush;
 
 /* bGPDbrush->flag */
@@ -546,6 +548,13 @@ typedef enum eGP_BrushType {
 	GP_BRUSH_TYPE_ERASE = 2,
 } eGP_BrushType;
 
+/* bGPDbrush->eraser_mode */
+typedef enum eGP_BrushEraserMode {
+	GP_BRUSH_ERASER_SOFT = 0,
+	GP_BRUSH_ERASER_HARD = 1,
+	GP_BRUSH_ERASER_STROKE = 2,
+} eGP_BrushEraserMode;
+
 /* xray modes (Depth Ordering) */
 typedef enum eGP_DepthOrdering {
 	GP_XRAY_FRONT = 0,
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 40bebaaac30..bc42f237088 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -451,6 +451,12 @@ static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = {
 	{ GP_FILL_DMODE_BOTH, "BOTH", 0, "Both", "Use visible strokes and control lines as fill boundary limits" },
 	{ 0, NULL, 0, NULL, NULL }
 };
+static EnumPropertyItem rna_enum_gpencil_brush_eraser_modes_items[] = {
+	{ GP_BRUSH_ERASER_SOFT, "SOFT", 0, "Soft", "Use soft eraser" },
+	{ GP_BRUSH_ERASER_HARD, "HARD", 0, "Hard", "Use hard eraser" },
+	{ GP_BRUSH_ERASER_STROKE, "STROKE", 0, "Stroke", "Use stroke eraser" },
+	{ 0, NULL, 0, NULL, NULL }
+};
 static EnumPropertyItem rna_enum_gpencil_brush_types_items[] = {
 	{ GP_BRUSH_TYPE_DRAW, "DRAW", 0, "Draw", "The brush is of type used for drawing strokes" },
 	{ GP_BRUSH_TYPE_FILL, "FILL", 0, "Fill", "The brush is of type used for filling areas" },
@@ -2458,13 +2464,16 @@ static void rna_def_gpencil_brush(BlenderRNA *brna)
 	RNA_def_property_enum_sdna(prop, NULL, "fill_draw_mode");
 	RNA_def_property_enum_items(prop, rna_enum_gpencil_fill_draw_modes_items);
 	RNA_def_property_ui_text(prop, "Mode", "Mode to draw boundary limits");
-	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 
 	prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "type");
 	RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_types_items);
 	RNA_def_property_ui_text(prop, "Type", "Category of the brush");
-	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+	prop = RNA_def_property(srna, "eraser_mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "eraser_mode");
+	RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_eraser_modes_items);
+	RNA_def_property_ui_text(prop, "Mode", "Eraser Mode");
 
 	prop = RNA_def_property(srna, "fill_show_boundary", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_SHOW_HELPLINES);



More information about the Bf-blender-cvs mailing list