Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_primitive.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 801dacb3e6b..b457cd819d2 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -1197,6 +1197,9 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
/* set GP datablock */
tgpi->gpd = gpd;
+ /* Setup space conversions. */
+ gpencil_point_conversion_init(C, &tgpi->gsc);
+
/* if brush doesn't exist, create a new set (fix damaged files from old versions) */
if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
BKE_brush_gpencil_paint_presets(bmain, ts, true);
@@ -1347,6 +1350,28 @@ static void gpencil_primitive_interaction_end(bContext *C,
}
}
+ /* Join previous stroke. */
+ if (ts->gpencil_flags & GP_TOOL_FLAG_AUTOMERGE_STROKE) {
+ if (ELEM(tgpi->type, GP_STROKE_ARC, GP_STROKE_LINE, GP_STROKE_CURVE, GP_STROKE_POLYLINE)) {
+ if (gps->prev != NULL) {
+ int pt_index = 0;
+ bool doit = true;
+ while (doit && gps) {
+ bGPDstroke *gps_target = ED_gpencil_stroke_nearest_to_ends(
+ C, &tgpi->gsc, tgpi->gpl, gpf, gps, GPENCIL_MINIMUM_JOIN_DIST, &pt_index);
+ if (gps_target != NULL) {
+ gps = ED_gpencil_stroke_join_and_trim(tgpi->gpd, gpf, gps, gps_target, pt_index);
+ }
+ else {
+ doit = false;
+ }
+ }
+ }
+ ED_gpencil_stroke_close_by_distance(gps, 0.02f);
+ }
+ BKE_gpencil_stroke_geometry_update(tgpi->gpd, gps);
+ }
+
DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_COPY_ON_WRITE);
DEG_id_tag_update(&tgpi->gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);