diff options
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_select.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_select.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index fff753cf3a9..1deeab641f4 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -861,11 +861,14 @@ void GPENCIL_OT_select_less(wmOperatorType *ot) * It would be great to de-duplicate the logic here sometime, but that can wait... */ static bool gp_stroke_do_circle_sel( + bGPDlayer *gpl, bGPDstroke *gps, GP_SpaceConversion *gsc, const int mx, const int my, const int radius, - const bool select, rcti *rect, float diff_mat[4][4], const int selectmode) + const bool select, rcti *rect, float diff_mat[4][4], const int selectmode, + const float scale) { - bGPDspoint *pt1, *pt2; + bGPDspoint *pt1 = NULL; + bGPDspoint *pt2 = NULL; int x0 = 0, y0 = 0, x1 = 0, y1 = 0; int i; bool changed = false; @@ -958,6 +961,14 @@ static bool gp_stroke_do_circle_sel( } } + /* expand selection to segment */ + if ((hit) && (selectmode == GP_SELECTMODE_SEGMENT) && (select)) { + float r_hita[3], r_hitb[3]; + bool hit_select = (bool)(pt1->flag & GP_SPOINT_SELECT); + ED_gpencil_select_stroke_segment( + gpl, gps, pt1, hit_select, false, scale, r_hita, r_hitb); + } + /* Ensure that stroke selection is in sync with its points */ BKE_gpencil_stroke_sync_selection(gps); } @@ -971,6 +982,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); ToolSettings *ts = CTX_data_tool_settings(C); const int selectmode = ts->gpencil_selectmode; + const float scale = ts->gp_sculpt.isect_threshold; /* if not edit/sculpt mode, the event is catched but not processed */ if (GPENCIL_NONE_EDIT_MODE(gpd)) { @@ -1012,7 +1024,8 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps) { changed |= gp_stroke_do_circle_sel( - gps, &gsc, mx, my, radius, select, &rect, gpstroke_iter.diff_mat, selectmode); + gpl, gps, &gsc, mx, my, radius, select, &rect, + gpstroke_iter.diff_mat, selectmode, scale); } GP_EDITABLE_STROKES_END(gpstroke_iter); @@ -1074,7 +1087,11 @@ static int gpencil_generic_select_exec( const bool strokemode = ( (ts->gpencil_selectmode == GP_SELECTMODE_STROKE) && ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)); + const bool segmentmode = ( + (ts->gpencil_selectmode == GP_SELECTMODE_SEGMENT) && + ((gpd->flag & GP_DATA_STROKE_PAINTMODE) == 0)); const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); + const float scale = ts->gp_sculpt.isect_threshold; GP_SpaceConversion gsc = {NULL}; @@ -1124,6 +1141,17 @@ static int gpencil_generic_select_exec( if (sel_op_result != -1) { SET_FLAG_FROM_TEST(pt->flag, sel_op_result, GP_SPOINT_SELECT); changed = true; + + /* expand selection to segment */ + if ((sel_op_result != -1) && + (segmentmode)) + { + bool hit_select = (bool)(pt->flag & GP_SPOINT_SELECT); + float r_hita[3], r_hitb[3]; + ED_gpencil_select_stroke_segment( + gpl, gps, pt, hit_select, false, scale, r_hita, r_hitb); + } + } } else { @@ -1336,6 +1364,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) ScrArea *sa = CTX_wm_area(C); bGPdata *gpd = ED_gpencil_data_get_active(C); ToolSettings *ts = CTX_data_tool_settings(C); + const float scale = ts->gp_sculpt.isect_threshold; /* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */ const float radius = 0.50f * U.widget_unit; @@ -1350,6 +1379,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) GP_SpaceConversion gsc = {NULL}; + bGPDlayer *hit_layer = NULL; bGPDstroke *hit_stroke = NULL; bGPDspoint *hit_point = NULL; int hit_distance = radius_squared; @@ -1394,6 +1424,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) if (pt_distance <= radius_squared) { /* only use this point if it is a better match than the current hit - T44685 */ if (pt_distance < hit_distance) { + hit_layer = gpl; hit_stroke = gps; hit_point = pt; hit_distance = pt_distance; @@ -1454,6 +1485,15 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* we're adding selection, so selection must be true */ hit_point->flag |= GP_SPOINT_SELECT; hit_stroke->flag |= GP_STROKE_SELECT; + + /* expand selection to segment */ + if (ts->gpencil_selectmode == GP_SELECTMODE_SEGMENT) { + float r_hita[3], r_hitb[3]; + bool hit_select = (bool)(hit_point->flag & GP_SPOINT_SELECT); + ED_gpencil_select_stroke_segment( + hit_layer, hit_stroke, hit_point, hit_select, + false, scale, r_hita, r_hitb); + } } else { /* deselect point */ |