GPencil: Apply Brush Size to Outline thickness while drawing

The new factor allows to apply the current brush size to the
external stroke perimeter conversion done in draw mode.
This commit is contained in:
Antonio Vazquez 2022-08-31 15:10:13 +02:00
parent 097ed6565e
commit ae79bc490a
4 changed files with 23 additions and 1 deletions

View File

@ -1742,12 +1742,18 @@ class VIEW3D_PT_tools_grease_pencil_brush_post_processing(View3DPanel, Panel):
col1 = col.column(align=True)
col1.prop(gp_settings, "use_trim")
col.separator()
row = col.row(heading="Outline", align=True)
row.prop(gp_settings, "use_settings_outline", text="")
row2 = row.row(align=True)
row2.enabled = gp_settings.use_settings_outline
row2.prop(gp_settings, "material_alt", text="")
row2 = col.row(align=True)
row2.enabled = gp_settings.use_settings_outline
row2.prop(gp_settings, "outline_thickness_factor")
class VIEW3D_PT_tools_grease_pencil_brush_random(View3DPanel, Panel):
bl_context = ".greasepencil_paint"

View File

@ -943,8 +943,9 @@ static bGPDstroke *gpencil_stroke_to_outline(tGPsdata *p, bGPDstroke *gps)
/* Stroke. */
float diff_mat[4][4];
unit_m4(diff_mat);
const float outline_thickness = (float)brush->size * gpencil_settings->outline_fac * 0.5f;
bGPDstroke *gps_perimeter = BKE_gpencil_stroke_perimeter_from_view(
rv3d, p->gpd, gpl, gps_duplicate, 3, diff_mat, 0.0f);
rv3d, p->gpd, gpl, gps_duplicate, 3, diff_mat, outline_thickness);
/* Assign material. */
if (gpencil_settings->material_alt == NULL) {
gps_perimeter->mat_nr = gps->mat_nr;
@ -961,6 +962,8 @@ static bGPDstroke *gpencil_stroke_to_outline(tGPsdata *p, bGPDstroke *gps)
}
/* Set pressure constant. */
gps_perimeter->thickness = max_ii((int)outline_thickness, 1);
bGPDspoint *pt;
for (int i = 0; i < gps_perimeter->totpoints; i++) {
pt = &gps_perimeter->points[i];

View File

@ -132,6 +132,10 @@ typedef struct BrushGpencilSettings {
struct CurveMapping *curve_rand_saturation;
struct CurveMapping *curve_rand_value;
/** Factor for external line thickness conversion to outline. */
float outline_fac;
char _pad1[4];
/* optional link of material to replace default in context */
/** Material. */
struct Material *material;

View File

@ -1654,6 +1654,15 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* Factor to determine outline external perimeter thickness. */
prop = RNA_def_property(srna, "outline_thickness_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "outline_fac");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_default(prop, 0.0f);
RNA_def_property_ui_text(
prop, "Thickness", "Thickness of the outline stroke relative to current brush thickness");
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, 0);
/* Flags */
prop = RNA_def_property(srna, "use_pressure", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_USE_PRESSURE);