From e9607f45d85df6df834a80f147b8c42ff12f56f2 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Wed, 18 Nov 2020 21:30:43 +0100 Subject: GPencil: Automerge last drawn stroke with previous strokes This option joins any stroke with an end near the actual stroke. Now it is not limited to the last stroke, any stroke in the same layer for the actual frame can be joined. The join can join two strokes drawing a third stroke. If the end and the start of the result stroke are very small, the stroke is changed to be cyclic automatically. There is a limit distance to join the stroke, if the distance is greater than this value, the strokes are not joined. Actually, a constant, threshold distance is used, but we could expose as a parameter in the UI in the future. The tool can be used with freehand drawing or with primitives. Note: Great part of the patch is just a refactor of the old code to make it accessible and to keep code organized. Reviewed By: mendio Maniphest Tasks: T82377 Differential Revision: https://developer.blender.org/D9440 --- source/blender/editors/include/ED_gpencil.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/blender/editors/include') diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 17aa407bd76..be2f714dfe1 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -63,6 +63,8 @@ struct bAnimContext; struct wmKeyConfig; struct wmOperator; +#define GPENCIL_MINIMUM_JOIN_DIST 20.0f + /* Reproject stroke modes. */ typedef enum eGP_ReprojectModes { /* Axis */ @@ -366,6 +368,22 @@ bool ED_gpencil_stroke_point_is_inside(struct bGPDstroke *gps, int mouse[2], const float diff_mat[4][4]); +struct bGPDstroke *ED_gpencil_stroke_nearest_to_ends(struct bContext *C, + struct GP_SpaceConversion *gsc, + struct bGPDlayer *gpl, + struct bGPDframe *gpf, + struct bGPDstroke *gps, + const float radius, + int *r_index); + +struct bGPDstroke *ED_gpencil_stroke_join_and_trim(struct bGPdata *gpd, + struct bGPDframe *gpf, + struct bGPDstroke *gps, + struct bGPDstroke *gps_dst, + const int pt_index); + +void ED_gpencil_stroke_close_by_distance(struct bGPDstroke *gps, const float threshold); + #ifdef __cplusplus } #endif -- cgit v1.2.3