[Bf-blender-cvs] [173b6b792cf] master: Cleanup: Split grease pencil selection index functions
Antonio Vazquez
noreply at git.blender.org
Sat Feb 20 10:17:08 CET 2021
Commit: 173b6b792cf95fb9eb20ec760b28469d46b0ff52
Author: Antonio Vazquez
Date: Sat Feb 20 10:16:51 2021 +0100
Branches: master
https://developer.blender.org/rB173b6b792cf95fb9eb20ec760b28469d46b0ff52
Cleanup: Split grease pencil selection index functions
This makes the code more readable.
===================================================================
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenkernel/intern/gpencil_curve.c
M source/blender/blenkernel/intern/gpencil_geom.c
M source/blender/editors/gpencil/gpencil_data.c
M source/blender/editors/gpencil/gpencil_edit.c
M source/blender/editors/gpencil/gpencil_merge.c
M source/blender/editors/gpencil/gpencil_primitive.c
M source/blender/editors/gpencil/gpencil_select.c
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/makesrna/intern/rna_gpencil.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index b9dba991d64..5cfdcf241d1 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -103,9 +103,8 @@ void BKE_gpencil_batch_cache_free(struct bGPdata *gpd);
void BKE_gpencil_stroke_sync_selection(struct bGPdata *gpd, struct bGPDstroke *gps);
void BKE_gpencil_curve_sync_selection(struct bGPdata *gpd, struct bGPDstroke *gps);
-void BKE_gpencil_stroke_select_index_set(struct bGPdata *gpd,
- struct bGPDstroke *gps,
- const bool reset);
+void BKE_gpencil_stroke_select_index_set(struct bGPdata *gpd, struct bGPDstroke *gps);
+void BKE_gpencil_stroke_select_index_reset(struct bGPDstroke *gps);
struct bGPDframe *BKE_gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe);
struct bGPDframe *BKE_gpencil_frame_addcopy(struct bGPDlayer *gpl, int cframe);
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);
diff --git a/source/blender/blenkernel/intern/gpencil_curve.c b/source/blender/blenkernel/intern/gpencil_curve.c
index a1cae205d39..88d3e917a7a 100644
--- a/source/blender/blenkernel/intern/gpencil_curve.c
+++ b/source/blender/blenkernel/intern/gpencil_curve.c
@@ -814,7 +814,7 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPdata *gpd, bGPDstroke *gps,
{
if (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);
for (int i = 0; i < gpc->tot_curve_points - 1; i++) {
bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
@@ -868,7 +868,7 @@ void BKE_gpencil_stroke_editcurve_sync_selection(bGPdata *gpd, bGPDstroke *gps,
}
else {
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
pt->flag &= ~GP_SPOINT_SELECT;
@@ -1093,7 +1093,7 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps,
/* deselect */
pt->flag &= ~GP_SPOINT_SELECT;
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
return;
}
@@ -1136,7 +1136,7 @@ void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps,
pt->flag &= ~GP_SPOINT_SELECT;
}
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
/* free temp data */
MEM_freeN(points);
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 2d10645a467..8c4882854d1 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -3444,7 +3444,7 @@ void BKE_gpencil_stroke_uniform_subdivide(bGPdata *gpd,
if (select) {
gps->flag |= GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(gpd, gps, false);
+ BKE_gpencil_stroke_select_index_set(gpd, gps);
}
/* Free the sample points. Important to use the mutable loop here because we are erasing the list
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 0597de445f4..c76c2e55d2b 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -3418,11 +3418,11 @@ static int gpencil_material_select_exec(bContext *C, wmOperator *op)
if (!deselected) {
gps->flag |= GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(gpd, gps, false);
+ BKE_gpencil_stroke_select_index_set(gpd, gps);
}
else {
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 (!deselected) {
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index aec593b97ea..b03d2c6e795 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -992,7 +992,7 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op)
pt->flag &= ~GP_SPOINT_SELECT;
}
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
changed = true;
}
@@ -1194,7 +1194,7 @@ static void gpencil_add_move_points(bGPdata *gpd, bGPDframe *gpf, bGPDstroke *gp
/* if the stroke is not reused, deselect */
if (!do_stroke) {
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
}
}
@@ -1711,7 +1711,7 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op)
}
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
}
CTX_DATA_END;
@@ -2551,7 +2551,7 @@ static bool gpencil_dissolve_selected_stroke_points(bContext *C,
/* deselect the stroke, since none of its selected points will still be selected */
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++) {
pt->flag &= ~GP_SPOINT_SELECT;
}
@@ -2624,7 +2624,7 @@ static int gpencil_delete_selected_points(bContext *C)
if (gps->flag & GP_STROKE_SELECT) {
/* deselect old stroke, since it will be used as template for the new strokes */
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
if (is_curve_edit) {
bGPDcurve *gpc = gps->editcurve;
@@ -4579,7 +4579,7 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
else if (mode == GP_SEPARATE_STROKE) {
/* deselect old stroke */
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
/* unlink from source frame */
BLI_remlink(&gpf->strokes, gps);
gps->prev = gps->next = NULL;
@@ -4988,7 +4988,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
}
gps->flag &= ~GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(NULL, gps, true);
+ BKE_gpencil_stroke_select_index_reset(gps);
}
CTX_DATA_END;
@@ -5029,7 +5029,7 @@ static int gpencil_cutter_lasso_select(bContext *C,
changed = true;
pt->flag |= GP_SPOINT_SELECT;
gps->flag |= GP_STROKE_SELECT;
- BKE_gpencil_stroke_select_index_set(gpd, gps, false);
+ BKE_gpencil_stroke_select_index_set(gpd, gps);
float r_hita[3], r_hitb[3];
if (gps->totpoints > 1) {
ED_gpencil_select_stroke_segment(
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index 8d8734dfd1f..259b2882589 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -134,7 +134,7 @@ static bGPDstroke *gpencil_prepare_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list