Fix T91463: Separate points makes gap on cyclic stroke

If an entire cyclic stroke was selected, calling "Separate by Points"
would leave a gap in the new object (making the new stroke non-cyclic).

The patch makes sure that if we separate by points and all points are
selected, we fall back to separate by stroke.

Reviewed By: antoniov

Maniphest Tasks: T91463

Differential Revision: https://developer.blender.org/D12527
This commit is contained in:
Falk David 2022-02-01 17:56:12 +01:00 committed by Antonio Vazquez
parent 2bd71b49e7
commit ffb0ecb498
Notes: blender-bot 2023-02-14 06:55:40 +01:00
Referenced by issue #91463, Grease Pencil: Separate Strokes - Selected Points Creates a Gap in the stroke
1 changed files with 25 additions and 0 deletions

View File

@ -4626,6 +4626,31 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Not implemented!");
}
else {
/* Check if all points are selected. */
bool all_points_selected = true;
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if ((pt->flag & GP_SPOINT_SELECT) == 0) {
all_points_selected = false;
break;
}
}
/* Separate the entrie stroke. */
if (all_points_selected) {
/* deselect old stroke */
gps->flag &= ~GP_STROKE_SELECT;
BKE_gpencil_stroke_select_index_reset(gps);
/* unlink from source frame */
BLI_remlink(&gpf->strokes, gps);
gps->prev = gps->next = NULL;
/* relink to destination frame */
BLI_addtail(&gpf_dst->strokes, gps);
/* Reassign material. */
gps->mat_nr = idx;
continue;
}
/* make copy of source stroke */
bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps, true, true);