diff options
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 1aec1ad296d..4167f60e880 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1134,7 +1134,7 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in * Ensure selection status of stroke is in sync with its points. * \param gps: Grease pencil stroke */ -void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps) +void BKE_gpencil_stroke_sync_selection(bGPdata *gpd, bGPDstroke *gps) { bGPDspoint *pt; int i; @@ -1148,6 +1148,7 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps) * so initially, we must deselect */ gps->flag &= ~GP_STROKE_SELECT; + BKE_gpencil_stroke_select_index_set(NULL, gps, true); for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) { @@ -1155,9 +1156,13 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps) break; } } + + if (gps->flag & GP_STROKE_SELECT) { + BKE_gpencil_stroke_select_index_set(gpd, gps, false); + } } -void BKE_gpencil_curve_sync_selection(bGPDstroke *gps) +void BKE_gpencil_curve_sync_selection(bGPdata *gpd, bGPDstroke *gps) { bGPDcurve *gpc = gps->editcurve; if (gpc == NULL) { @@ -1165,6 +1170,7 @@ void BKE_gpencil_curve_sync_selection(bGPDstroke *gps) } gps->flag &= ~GP_STROKE_SELECT; + BKE_gpencil_stroke_select_index_set(NULL, gps, true); gpc->flag &= ~GP_CURVE_SELECT; bool is_selected = false; @@ -1187,6 +1193,19 @@ void BKE_gpencil_curve_sync_selection(bGPDstroke *gps) if (is_selected) { gpc->flag |= GP_CURVE_SELECT; gps->flag |= GP_STROKE_SELECT; + BKE_gpencil_stroke_select_index_set(gpd, gps, false); + } +} + +/* Assign unique stroke ID for selection. */ +void BKE_gpencil_stroke_select_index_set(bGPdata *gpd, bGPDstroke *gps, const bool reset) +{ + if (!reset) { + gpd->select_last_index++; + gps->select_index = gpd->select_last_index; + } + else { + gps->select_index = 0; } } @@ -2512,6 +2531,11 @@ bool BKE_gpencil_from_image( pt->flag |= GP_SPOINT_SELECT; } } + + if (gps->flag & GP_STROKE_SELECT) { + BKE_gpencil_stroke_select_index_set(gpd, gps, false); + } + BKE_gpencil_stroke_geometry_update(gpd, gps); } } |