diff options
author | Falk David <filedescriptor> | 2022-02-01 19:56:12 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2022-02-01 20:09:34 +0300 |
commit | ffb0ecb4985b133af7d97d61130a93f716c31f9e (patch) | |
tree | 603688a0442c0457e4e734d7a3820ef55bb34d8f | |
parent | 2bd71b49e79325863bfe3c561fa03653231c9914 (diff) |
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
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index e71a56894d0..afb786da8c6 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -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); |