diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2022-08-31 16:10:13 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2022-08-31 17:18:08 +0300 |
commit | ae79bc490a761cf351f09514356994d6efd586db (patch) | |
tree | d34eef42409c5b16852549b21f4e901d916d33a9 /source | |
parent | 097ed6565edd27c8178a764fe6dbacb1ba75ef52 (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_brush_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 9 |
3 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index b196fcae51c..cbc88b57c65 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -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]; diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 174ec614238..33f5d8eea12 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -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; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 989b0654104..2aa0a1bba01 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -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); |