[Bf-blender-cvs] [56e104b8196] soc-2021-curves: Reduced select distance threshold
dilithjay
noreply at git.blender.org
Mon Dec 13 14:59:39 CET 2021
Commit: 56e104b81962e48e1a840573b3441396dab8d829
Author: dilithjay
Date: Sat Dec 11 23:21:02 2021 +0530
Branches: soc-2021-curves
https://developer.blender.org/rB56e104b81962e48e1a840573b3441396dab8d829
Reduced select distance threshold
===================================================================
M release/datafiles/locale
M release/scripts/addons
M source/blender/editors/curve/curve_intern.h
M source/blender/editors/curve/editcurve.c
M source/blender/editors/curve/editcurve_pen.c
M source/blender/editors/curve/editcurve_query.c
M source/blender/editors/include/ED_curve.h
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 3a78acbab9f..620b85f16d0 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 3a78acbab9f63b18e93c1fa72b68a85e1bdeba05
+Subproject commit 620b85f16d03a6aadd7cae56969c9c29b06b992d
diff --git a/release/scripts/addons b/release/scripts/addons
index a444e8cc19a..c60fef38175 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit a444e8cc19a4353ce35ecdec9bb7894ee73a204a
+Subproject commit c60fef38175ad989ee0c45e924cb27e1417c8667
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h
index 23e4502d017..b4e9d9a78a3 100644
--- a/source/blender/editors/curve/curve_intern.h
+++ b/source/blender/editors/curve/curve_intern.h
@@ -215,6 +215,14 @@ bool ED_curve_pick_vert(struct ViewContext *vc,
struct BPoint **r_bp,
short *r_handle,
struct Base **r_base);
+bool ED_curve_pick_vert_thresholded(struct ViewContext *vc,
+ short sel,
+ const float sel_dist_mul,
+ struct Nurb **r_nurb,
+ struct BezTriple **r_bezt,
+ struct BPoint **r_bp,
+ short *r_handle,
+ struct Base **r_base);
void ED_curve_nurb_vert_selected_find(
Curve *cu, View3D *v3d, Nurb **r_nu, BezTriple **r_bezt, BPoint **r_bp);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 4772c8dfa98..771c837da08 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -4744,9 +4744,18 @@ void CURVE_OT_make_segment(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
/** \name Pick Select from 3D View
* \{ */
-
bool ED_curve_editnurb_select_pick(
bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
+{
+ return ED_curve_editnurb_select_pick_thresholded(C, mval, 1.0f, extend, deselect, toggle);
+}
+
+bool ED_curve_editnurb_select_pick_thresholded(bContext *C,
+ const int mval[2],
+ const float sel_dist_mul,
+ bool extend,
+ bool deselect,
+ bool toggle)
{
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewContext vc;
@@ -4760,7 +4769,7 @@ bool ED_curve_editnurb_select_pick(
ED_view3d_viewcontext_init(C, &vc, depsgraph);
copy_v2_v2_int(vc.mval, mval);
- if (ED_curve_pick_vert(&vc, 1, &nu, &bezt, &bp, &hand, &basact)) {
+ if (ED_curve_pick_vert_thresholded(&vc, 1, sel_dist_mul, &nu, &bezt, &bp, &hand, &basact)) {
Object *obedit = basact->object;
Curve *cu = obedit->data;
ListBase *editnurb = object_editcurve_get(obedit);
diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c
index 1a6389474bd..629db825f28 100644
--- a/source/blender/editors/curve/editcurve_pen.c
+++ b/source/blender/editors/curve/editcurve_pen.c
@@ -45,6 +45,8 @@
#include "float.h"
+#define SEL_DIST_MUL 0.4f
+
/* Data structure to keep track of details about the cut location */
typedef struct CutData {
/* Index of the last #BezTriple or BPoint before the cut. */
@@ -745,7 +747,7 @@ static bool is_spline_nearby(ViewContext *vc, wmOperator *op, const wmEvent *eve
update_data_for_all_nurbs(nurbs, vc, &data);
- const float threshold_distance = ED_view3d_select_dist_px() * 0.3f;
+ const float threshold_distance = ED_view3d_select_dist_px() * SEL_DIST_MUL;
if (data.nurb && !data.nurb->bp && data.min_dist < threshold_distance) {
MoveSegmentData *seg_data;
op->customdata = seg_data = MEM_callocN(sizeof(MoveSegmentData), __func__);
@@ -966,7 +968,8 @@ static int curve_pen_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* Get currently selected point if any. Used for making spline cyclic. */
ED_curve_nurb_vert_selected_find(cu, vc.v3d, &nu, &bezt, &bp);
- const bool found_point = ED_curve_editnurb_select_pick(C, event->mval, false, false, false);
+ const bool found_point = ED_curve_editnurb_select_pick_thresholded(
+ C, event->mval, SEL_DIST_MUL, false, false, false);
RNA_boolean_set(op->ptr, "new", !found_point);
if (found_point) {
diff --git a/source/blender/editors/curve/editcurve_query.c b/source/blender/editors/curve/editcurve_query.c
index a8fd3ea2803..b39dc0dd1e8 100644
--- a/source/blender/editors/curve/editcurve_query.c
+++ b/source/blender/editors/curve/editcurve_query.c
@@ -104,13 +104,14 @@ static void ED_curve_pick_vert__do_closest(void *userData,
UNUSED_VARS_NDEBUG(handles_visible);
}
-bool ED_curve_pick_vert(ViewContext *vc,
- short sel,
- Nurb **r_nurb,
- BezTriple **r_bezt,
- BPoint **r_bp,
- short *r_handle,
- Base **r_base)
+bool ED_curve_pick_vert_thresholded(ViewContext *vc,
+ short sel,
+ const float sel_dist_mul,
+ Nurb **r_nurb,
+ BezTriple **r_bezt,
+ BPoint **r_bp,
+ short *r_handle,
+ Base **r_base)
{
/* (sel == 1): selected gets a disadvantage */
/* in nurb and bezt or bp the nearest is written */
@@ -125,7 +126,7 @@ bool ED_curve_pick_vert(ViewContext *vc,
bool is_changed;
} data = {NULL};
- data.dist = ED_view3d_select_dist_px();
+ data.dist = ED_view3d_select_dist_px() * sel_dist_mul;
data.hpoint = 0;
data.select = sel;
data.mval_fl[0] = vc->mval[0];
@@ -159,6 +160,17 @@ bool ED_curve_pick_vert(ViewContext *vc,
return (data.bezt || data.bp);
}
+bool ED_curve_pick_vert(ViewContext *vc,
+ short sel,
+ Nurb **r_nurb,
+ BezTriple **r_bezt,
+ BPoint **r_bp,
+ short *r_handle,
+ Base **r_base)
+{
+ return ED_curve_pick_vert_thresholded(vc, 1, 1.0f, r_nurb, r_bezt, r_bp, r_handle, r_base);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h
index 805d42b6fbc..0315b0a5e75 100644
--- a/source/blender/editors/include/ED_curve.h
+++ b/source/blender/editors/include/ED_curve.h
@@ -62,6 +62,12 @@ void ED_curve_editnurb_load(struct Main *bmain, struct Object *obedit);
void ED_curve_editnurb_make(struct Object *obedit);
void ED_curve_editnurb_free(struct Object *obedit);
+bool ED_curve_editnurb_select_pick_thresholded(struct bContext *C,
+ const int mval[2],
+ const float sel_dist_mul,
+ bool extend,
+ bool deselect,
+ bool toggle);
bool ED_curve_editnurb_select_pick(
struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
More information about the Bf-blender-cvs
mailing list