From dc5b1d6c75717a41c00042b667bc4a1a1609e588 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Apr 2022 13:11:44 +1000 Subject: Cleanup: pass selection threshold to curve picking Remove the extended version of ED_curve_editnurb_select_pick, pass the size threshold directly to this function but as the distance in pixels instead of a multiplier for ED_view3d_select_dist_px. Using a multiplier is a less direct way to reference the threshold. --- source/blender/editors/curve/editcurve_pen.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/curve/editcurve_pen.c') diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c index e3a2bd479bb..0524159fe54 100644 --- a/source/blender/editors/curve/editcurve_pen.c +++ b/source/blender/editors/curve/editcurve_pen.c @@ -844,8 +844,9 @@ static bool insert_point_to_segment(const ViewContext *vc, const wmEvent *event) Curve *cu = vc->obedit->data; CutData cd = init_cut_data(event); float mval[2] = {UNPACK2(event->mval)}; + const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR; const bool near_spline = update_cut_data_for_all_nurbs( - vc, BKE_curve_editNurbs_get(cu), mval, SEL_DIST_FACTOR * ED_view3d_select_dist_px(), &cd); + vc, BKE_curve_editNurbs_get(cu), mval, threshold_dist_px, &cd); if (near_spline && !cd.nurb->hide) { Nurb *nu = cd.nurb; @@ -1554,6 +1555,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_view3d_viewcontext_init(C, &vc, depsgraph); Curve *cu = vc.obedit->data; ListBase *nurbs = &cu->editnurb->nurbs; + const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR; BezTriple *bezt = NULL; BPoint *bp = NULL; @@ -1655,7 +1657,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) else if (ELEM(event->type, LEFTMOUSE)) { if (ELEM(event->val, KM_RELEASE, KM_DBL_CLICK)) { if (delete_point && !cpd->new_point && !cpd->dragging) { - if (ED_curve_editnurb_select_pick_ex(C, event->mval, SEL_DIST_FACTOR, ¶ms)) { + if (ED_curve_editnurb_select_pick(C, event->mval, threshold_dist_px, ¶ms)) { cpd->acted = delete_point_under_mouse(&vc, event); } } @@ -1714,7 +1716,7 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (select_point) { - ED_curve_editnurb_select_pick_ex(C, event->mval, SEL_DIST_FACTOR, ¶ms); + ED_curve_editnurb_select_pick(C, event->mval, threshold_dist_px, ¶ms); } } @@ -1749,6 +1751,7 @@ static int curve_pen_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* Distance threshold for mouse clicks to affect the spline or its points */ const float mval_fl[2] = {UNPACK2(event->mval)}; + const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR; const bool extrude_point = RNA_boolean_get(op->ptr, "extrude_point"); const bool insert_point = RNA_boolean_get(op->ptr, "insert_point"); @@ -1804,7 +1807,7 @@ static int curve_pen_invoke(bContext *C, wmOperator *op, const wmEvent *event) } } else if (!cpd->acted) { - if (is_spline_nearby(&vc, op, event, SEL_DIST_FACTOR * ED_view3d_select_dist_px())) { + if (is_spline_nearby(&vc, op, event, threshold_dist_px)) { cpd->spline_nearby = true; /* If move segment is disabled, then insert point on key press and set -- cgit v1.2.3