[Bf-blender-cvs] [1d76fbf3df6] blender2.8: GP: Add thickness and stregth factor to UI

Antonioya noreply at git.blender.org
Fri Sep 14 10:32:12 CEST 2018


Commit: 1d76fbf3df69db6939145b5a1cac7a5d6a482375
Author: Antonioya
Date:   Fri Sep 14 10:31:47 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB1d76fbf3df69db6939145b5a1cac7a5d6a482375

GP: Add thickness and stregth factor to UI

Now it's possible change the factors for soft eraser.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/editors/gpencil/gpencil_paint.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 0f774b1b21e..1ef13a89548 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1427,6 +1427,11 @@ class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel):
 
                 row = layout.row(align=True)
                 row.prop(gp_settings, "eraser_mode", expand=True)
+                if gp_settings.eraser_mode == 'SOFT':
+                    row = layout.row(align=True)
+                    row.prop(gp_settings, "eraser_strength_factor")
+                    row = layout.row(align=True)
+                    row.prop(gp_settings, "eraser_thickness_factor")
             elif gp_settings.gpencil_brush_type == 'FILL':
                 col = layout.column(align=True)
                 col.prop(gp_settings, "gpencil_fill_leak", text="Leak Size")
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index a35c0531059..3cf65330b3e 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1944,5 +1944,17 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 				}
 			}
 		}
+
+		if (!DNA_struct_elem_find(fd->filesdna, "BrushGpencilSettings", "float", "era_strength_f")) {
+			for (Brush *brush = bmain->brush.first; brush; brush = brush->id.next) {
+				if (brush->gpencil_settings != NULL) {
+					BrushGpencilSettings *gp = brush->gpencil_settings;
+					if (gp->brush_type == GP_BRUSH_TYPE_ERASE) {
+						gp->era_strength_f = 1.0f;
+						gp->era_thickness_f = 0.1f;
+					}
+				}
+			}
+		}
 	}
 }
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 1aea1e467b0..8239afd1a48 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1532,19 +1532,22 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p,
 
 						/* Adjust strength if the eraser is soft */
 						if (eraser->gpencil_settings->eraser_mode == GP_BRUSH_ERASER_SOFT) {
+							float f_strength = eraser->gpencil_settings->era_strength_f;
+							float f_thickness = eraser->gpencil_settings->era_thickness_f;
+
 							if (pt0) {
-								pt0->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc0) * strength * 0.5f;
+								pt0->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc0) * strength * f_strength * 0.5f;
 								CLAMP_MIN(pt0->strength, 0.0f);
-								pt0->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc0) * strength * 0.05f;
+								pt0->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc0) * strength * f_thickness * 0.5f;
 							}
 
-							pt1->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength;
+							pt1->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength * f_strength;
 							CLAMP_MIN(pt1->strength, 0.0f);
-							pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength * 0.10f;
+							pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength * f_thickness;
 
-							pt2->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * 0.5f;
+							pt2->strength -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * f_strength * 0.5f;
 							CLAMP_MIN(pt2->strength, 0.0f);
-							pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * 0.05f;
+							pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength * f_thickness * 0.5f;
 
 							/* if invisible, delete point */
 							if ((pt0) &&
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 09d5ec92859..970605d6be7 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -84,6 +84,8 @@ typedef struct BrushGpencilSettings {
 	int   brush_type;      /* type of brush (draw, fill, erase, etc..) */
 	int   eraser_mode;     /* soft, hard or stroke */
 	float active_smooth;   /* smooth while drawing factor */
+	float era_strength_f;  /* factor to apply to strength for soft eraser */
+	float era_thickness_f; /* factor to apply to thickness for soft eraser */
 	char pad_2[4];
 
 	struct CurveMapping *curve_sensitivity;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 111c187a407..00209accee7 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1163,6 +1163,22 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
 	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
+	prop = RNA_def_property(srna, "eraser_strength_factor", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "era_strength_f");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Strength Factor",
+		"Amount of erasing for strength ");
+	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
+	prop = RNA_def_property(srna, "eraser_thickness_factor", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "era_thickness_f");
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_ui_text(prop, "Thickness Factor",
+		"Amount of erasing for thickness ");
+	RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
 	/* brush standard icon */
 	prop = RNA_def_property(srna, "gp_icon", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "icon_id");



More information about the Bf-blender-cvs mailing list