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
This commit is contained in:
2020-11-18 21:30:43 +01:00
committed by Antonio Vazquez
parent c126e27cdc
commit e9607f45d8
14 changed files with 910 additions and 597 deletions

View File

@@ -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