GP: Add thickness and stregth factor to UI
Now it's possible change the factors for soft eraser.
This commit is contained in:
parent
18141863b2
commit
1d76fbf3df
|
@ -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")
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) &&
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue