From 468f2ccc0ecbcb368aab950c61c2cc0bc95b27e1 Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Fri, 16 Sep 2022 10:53:07 +0200 Subject: GPencil: Add more types of stroke extensions when filling The motivation for this change: while working on an animation recently, I found that there are some gaps that won't close easily via stroke extension or leak size checking. In D14698, I attempted to address this by changing the algorithm of the raster-space flood fill. This patch attempts to address the same issue in vector space by adding two new cases where stroke extensions are added, as suggested by @frogstomp: # **Points of high curvature:** when the curvature at a point is high enough that it's hard to visually distinguish between it and an endpoint, add a stroke extension out along the normal (pointing in the opposite direction of the stroke's acceleration.) This addresses cases where technically the endpoint points up, but there's a sharp corner right below it that should extend to connect. # **Stroke endpoints within a radius**: when two endpoints are close together, regardless of the angle they make, connect them if they are within a radius. This addresses cases like where the two endpoints have effectively parallel tangents, so extensions won't close the gap. Reviewed By: antoniov, mendio, frogstomp Differential Revision: https://developer.blender.org/D14809 --- source/blender/makesdna/DNA_brush_enums.h | 9 ++++++++- source/blender/makesdna/DNA_brush_types.h | 4 +++- source/blender/makesdna/DNA_gpencil_types.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'source/blender/makesdna') diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h index 988853e6694..0762d304313 100644 --- a/source/blender/makesdna/DNA_brush_enums.h +++ b/source/blender/makesdna/DNA_brush_enums.h @@ -118,13 +118,20 @@ typedef enum eGPDbrush_Flag2 { GP_BRUSH_USE_UV_RAND_PRESS = (1 << 11), } eGPDbrush_Flag2; -/* BrushGpencilSettings->gp_fill_draw_mode */ +/* BrushGpencilSettings->fill_draw_mode */ typedef enum eGP_FillDrawModes { GP_FILL_DMODE_BOTH = 0, GP_FILL_DMODE_STROKE = 1, GP_FILL_DMODE_CONTROL = 2, } eGP_FillDrawModes; +/* BrushGpencilSettings->fill_extend_mode */ +typedef enum eGP_FillExtendModes { + GP_FILL_EMODE_LINES_AND_CIRCLES = 0, + GP_FILL_EMODE_LINES = 1, + GP_FILL_EMODE_CIRCLES = 2, +} eGP_FillExtendModes; + /* BrushGpencilSettings->fill_layer_mode */ typedef enum eGP_FillLayerModes { GP_FILL_GPLMODE_VISIBLE = 0, diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index 33f5d8eea12..f91321c253f 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -62,7 +62,7 @@ typedef struct BrushGpencilSettings { short fill_leak; /* Type of caps: eGPDstroke_Caps. */ int8_t caps_type; - char _pad; + char _pad[5]; int flag2; @@ -70,6 +70,8 @@ typedef struct BrushGpencilSettings { int fill_simplylvl; /** Type of control lines drawing mode. */ int fill_draw_mode; + /** Type of gap filling to use */ + int fill_extend_mode; /** Icon identifier. */ int icon_id; diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 6a2f25f3975..17b25021277 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -347,6 +347,8 @@ typedef enum eGPDstroke_Flag { /* Flag to indicated that the editcurve has been changed and the stroke needs to be updated with * the curve data */ GP_STROKE_NEEDS_CURVE_UPDATE = (1 << 9), + /* Flag to indicate that a stroke is used only for help, and will not affect rendering or fill */ + GP_STROKE_HELP = (1 << 10), /* only for use with stroke-buffer (while drawing arrows) */ GP_STROKE_USE_ARROW_START = (1 << 12), /* only for use with stroke-buffer (while drawing arrows) */ -- cgit v1.2.3