diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2021-02-20 12:16:51 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2021-02-20 12:16:59 +0300 |
commit | 173b6b792cf95fb9eb20ec760b28469d46b0ff52 (patch) | |
tree | d1ae9e54c06d3972e7bba5fe2c667a35a51fbf29 /source/blender/blenkernel/intern/gpencil.c | |
parent | 37e6a1995ac7eeabd5b6a56621ad5a850dae4149 (diff) |
Cleanup: Split grease pencil selection index functions
This makes the code more readable.
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 4167f60e880..28477e9dc30 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1148,7 +1148,7 @@ void BKE_gpencil_stroke_sync_selection(bGPdata *gpd, bGPDstroke *gps) * so initially, we must deselect */ gps->flag &= ~GP_STROKE_SELECT; - BKE_gpencil_stroke_select_index_set(NULL, gps, true); + BKE_gpencil_stroke_select_index_reset(gps); for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) { @@ -1158,7 +1158,7 @@ void BKE_gpencil_stroke_sync_selection(bGPdata *gpd, bGPDstroke *gps) } if (gps->flag & GP_STROKE_SELECT) { - BKE_gpencil_stroke_select_index_set(gpd, gps, false); + BKE_gpencil_stroke_select_index_set(gpd, gps); } } @@ -1170,7 +1170,7 @@ void BKE_gpencil_curve_sync_selection(bGPdata *gpd, bGPDstroke *gps) } gps->flag &= ~GP_STROKE_SELECT; - BKE_gpencil_stroke_select_index_set(NULL, gps, true); + BKE_gpencil_stroke_select_index_reset(gps); gpc->flag &= ~GP_CURVE_SELECT; bool is_selected = false; @@ -1193,20 +1193,21 @@ void BKE_gpencil_curve_sync_selection(bGPdata *gpd, bGPDstroke *gps) if (is_selected) { gpc->flag |= GP_CURVE_SELECT; gps->flag |= GP_STROKE_SELECT; - BKE_gpencil_stroke_select_index_set(gpd, gps, false); + BKE_gpencil_stroke_select_index_set(gpd, gps); } } /* Assign unique stroke ID for selection. */ -void BKE_gpencil_stroke_select_index_set(bGPdata *gpd, bGPDstroke *gps, const bool reset) +void BKE_gpencil_stroke_select_index_set(bGPdata *gpd, bGPDstroke *gps) { - if (!reset) { - gpd->select_last_index++; - gps->select_index = gpd->select_last_index; - } - else { - gps->select_index = 0; - } + gpd->select_last_index++; + gps->select_index = gpd->select_last_index; +} + +/* Reset unique stroke ID for selection. */ +void BKE_gpencil_stroke_select_index_reset(bGPDstroke *gps) +{ + gps->select_index = 0; } /* ************************************************** */ @@ -2533,7 +2534,7 @@ bool BKE_gpencil_from_image( } if (gps->flag & GP_STROKE_SELECT) { - BKE_gpencil_stroke_select_index_set(gpd, gps, false); + BKE_gpencil_stroke_select_index_set(gpd, gps); } BKE_gpencil_stroke_geometry_update(gpd, gps); |