Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/versioning_280.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c15
-rw-r--r--source/blender/makesdna/DNA_brush_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_brush.c16
4 files changed, 39 insertions, 6 deletions
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");