diff options
author | Jonathan deWerd <jjoonathan@gmail.com> | 2014-08-01 15:39:25 +0400 |
---|---|---|
committer | Jonathan deWerd <jjoonathan@gmail.com> | 2014-08-01 15:39:25 +0400 |
commit | be8b5ecc84a90c2673366de3f2e61ca2fafc8674 (patch) | |
tree | 9c6a4cd96265867caa67f922e5e47dd3ae01612e | |
parent | 98e5beabb5076a7e8a4cf08031955cc2353617ae (diff) |
Added support for loop-select and adjusted disply of NURBS control polygon to 1: use z-test, 2: appear 'thin'.
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 135 | ||||
-rw-r--r-- | source/blender/editors/include/ED_curve.h | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 4 | ||||
-rw-r--r-- | source/blender/editors/io/io_rhino_import.cpp | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 26 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_buttons.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_iterators.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 11 |
12 files changed, 176 insertions, 47 deletions
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 2955c5c01c9..bb06f29f12f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -165,6 +165,28 @@ static bool select_bpoint(BPoint *bp, bool selstatus, short flag, bool hidden) return false; } +/* Helper to select all points in a UV row or column according to dir */ +static bool nurbs_select_bpoint(Nurb *nu, BPoint *bp, int dir, bool selstatus, short flag, bool hidden) { + int pntsu = (nu->pntsu<=1)? 1 : nu->pntsu; + int pntsv = (nu->pntsv<=1)? 1 : nu->pntsv; + int idx = bp - nu->bp; + BLI_assert(0<=idx && idx<pntsu*pntsv); + int uidx = idx%pntsu; + int vidx = idx/pntsu; + /* dir is 0:-v 1:+v 2:-u 3:+u */ + if (dir==2 || dir==3) { + for (int u=0; u<pntsu; u++) { + select_bpoint(&nu->bp[pntsu*vidx+u], selstatus, flag, hidden); + } + } + if (dir==0 || dir==1) { + for (int v=0; v<pntsv; v++) { + select_bpoint(&nu->bp[pntsu*v+uidx], selstatus, flag, hidden); + } + } + return true; +} + static bool swap_selection_beztriple(BezTriple *bezt) { if (bezt->f2 & SELECT) @@ -3772,9 +3794,9 @@ void CURVE_OT_subdivide(wmOperatorType *ot) /******************** find nearest ************************/ -static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) +static void findnearestNurbvert__doClosest(ViewContext *vc, void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) { - struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; float dist; int hpoint, select; float mval_fl[2]; } *data = userData; + struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int *dir; float dist; int hpoint, select; float mval_fl[2]; } *data = userData; short flag; float dist_test; @@ -3800,26 +3822,85 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, if (dist_test < data->dist) { data->dist = dist_test; - data->bp = bp; data->bezt = bezt; data->nurb = nu; data->hpoint = bezt ? beztindex : 0; - } -} - -static short findnearestNurbvert(ViewContext *vc, short sel, const int mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp) + if (nu->type==CU_NURBS && data->dir) { + int pntsu = (nu->pntsu<=1)? 1 : nu->pntsu; + int pntsv = (nu->pntsu<=1)? 1 : nu->pntsv; + int idx = bp - nu->bp; + BLI_assert(0<=idx && idx<pntsu*pntsv); + int uidx = idx%pntsu; + int vidx = idx/pntsu; + float max_cos = -2.0; *data->dir=-1; + float compass_pt[2]; /* pos of adjacent bp in {+u,-u,+v,-v} direction */ + float compass_dir[2]; /* bp ---> bp{+u,-u,+v,-v} */ + float mouse_dir[2]; /* bp ---> clickpt */ + sub_v2_v2v2(mouse_dir, data->mval_fl, screen_co); + normalize_v2(mouse_dir); + *data->dir = -1; + BPoint *Upos = (uidx<pntsu-1)? bp+1 : NULL; + if (Upos && ED_view3d_project_float_object(vc->ar, Upos->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { + sub_v2_v2v2(compass_dir, compass_pt, screen_co); + normalize_v2(compass_dir); + float cos = dot_v2v2(compass_dir, mouse_dir); + /* data->dir for directional select (alt+click) 0:-v 1:+v 2:-u 3:+u */ + if (cos>max_cos) { + *data->dir = 3; + max_cos = cos; + } + } + BPoint *Uneg = (uidx>0)? bp-1 : NULL; + if (Uneg && ED_view3d_project_float_object(vc->ar, Uneg->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { + sub_v2_v2v2(compass_dir, compass_pt, screen_co); + normalize_v2(compass_dir); + float cos = dot_v2v2(compass_dir, mouse_dir); + /* data->dir for directional select (alt+click) 0:-v 1:+v 2:-u 3:+u */ + if (cos>max_cos) { + *data->dir = 2; + max_cos = cos; + } + } + BPoint *Vpos = (vidx<pntsv-1)? bp+pntsu : NULL; + if (Vpos && ED_view3d_project_float_object(vc->ar, Vpos->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { + sub_v2_v2v2(compass_dir, compass_pt, screen_co); + normalize_v2(compass_dir); + float cos = dot_v2v2(compass_dir, mouse_dir); + /* data->dir for directional select (alt+click) 0:-v 1:+v 2:-u 3:+u */ + if (cos>max_cos) { + *data->dir = 1; + max_cos = cos; + } + } + BPoint *Vneg = (vidx>0)? bp-pntsu : NULL; + if (Vneg && ED_view3d_project_float_object(vc->ar, Vneg->vec, compass_pt, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { + sub_v2_v2v2(compass_dir, compass_pt, screen_co); + normalize_v2(compass_dir); + float cos = dot_v2v2(compass_dir, mouse_dir); + /* data->dir for directional select (alt+click) 0:-v 1:+v 2:-u 3:+u */ + if (cos>max_cos) { + *data->dir = 0; + max_cos = cos; + } + } + } + } +} + +static short findnearestNurbvert(ViewContext *vc, short sel, const int mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp, int *dir) { /* (sel == 1): selected gets a disadvantage */ /* in nurb and bezt or bp the nearest is written */ /* return 0 1 2: handlepunt */ - struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; float dist; int hpoint, select; float mval_fl[2]; } data = {NULL}; + struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int *dir; float dist; int hpoint, select; float mval_fl[2]; } data = {NULL}; data.dist = ED_view3d_select_dist_px(); data.hpoint = 0; data.select = sel; data.mval_fl[0] = mval[0]; data.mval_fl[1] = mval[1]; + data.dir = dir; ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); nurbs_foreachScreenVert(vc, findnearestNurbvert__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT); @@ -4637,7 +4718,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) /***************** pick select from 3d view **********************/ -bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) +bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool alt) { Object *obedit = CTX_data_edit_object(C); Curve *cu = obedit->data; @@ -4655,7 +4736,8 @@ bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool location[0] = mval[0]; location[1] = mval[1]; - hand = findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); + int dir; /* for directional select (alt+click) 0:-v 1:+v 2:-u 3:+u */ + hand = findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp, &dir); if (bezt || bp) { if (extend) { @@ -4673,7 +4755,11 @@ bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool } else { BKE_curve_nurb_vert_active_set(cu, nu, bp); - select_bpoint(bp, SELECT, SELECT, HIDDEN); + if (nu->type==CU_NURBS && alt) { /* Loop select */ + nurbs_select_bpoint(nu, bp, dir, SELECT, SELECT, HIDDEN); + } else { /* Just select bp */ + select_bpoint(bp, SELECT, SELECT, HIDDEN); + } } } else if (deselect) { @@ -4690,7 +4776,11 @@ bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool } } else { - select_bpoint(bp, DESELECT, SELECT, HIDDEN); + if (nu->type==CU_NURBS && alt) { /* Loop select */ + nurbs_select_bpoint(nu, bp, dir, DESELECT, SELECT, HIDDEN); + } else { /* Just select bp */ + select_bpoint(bp, DESELECT, SELECT, HIDDEN); + } if (bp == vert) cu->actvert = CU_ACT_NONE; } } @@ -4715,11 +4805,19 @@ bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool } else { if (bp->f1 & SELECT) { - select_bpoint(bp, DESELECT, SELECT, HIDDEN); + if (nu->type==CU_NURBS && alt) { /* Loop select */ + nurbs_select_bpoint(nu, bp, dir, DESELECT, SELECT, HIDDEN); + } else { /* Just select bp */ + select_bpoint(bp, DESELECT, SELECT, HIDDEN); + } if (bp == vert) cu->actvert = CU_ACT_NONE; } else { - select_bpoint(bp, SELECT, SELECT, HIDDEN); + if (nu->type==CU_NURBS && alt) { /* Loop select */ + nurbs_select_bpoint(nu, bp, dir, SELECT, SELECT, HIDDEN); + } else { /* Just select bp */ + select_bpoint(bp, SELECT, SELECT, HIDDEN); + } BKE_curve_nurb_vert_active_set(cu, nu, bp); } } @@ -4742,7 +4840,11 @@ bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool } else { BKE_curve_nurb_vert_active_set(cu, nu, bp); - select_bpoint(bp, SELECT, SELECT, HIDDEN); + if (nu->type==CU_NURBS && alt) { /* Loop select */ + nurbs_select_bpoint(nu, bp, dir, SELECT, SELECT, HIDDEN); + } else { /* Just select bp */ + select_bpoint(bp, SELECT, SELECT, HIDDEN); + } } } @@ -5520,7 +5622,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, const wmEvent view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp); + int dir; + findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp, &dir); if (bezt) { a = nu->pntsu; diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 330147db077..4725cf8f1c1 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -64,7 +64,7 @@ void load_editNurb(struct Object *obedit); void make_editNurb(struct Object *obedit); void free_editNurb(struct Object *obedit); -bool mouse_nurb(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); +bool mouse_nurb(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool alt); struct Nurb *add_nurbs_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newob); diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index d31be3e961f..4dae067bb5a 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -161,6 +161,7 @@ int ED_operator_object_active_editable_font(struct bContext *C); int ED_operator_editmesh(struct bContext *C); int ED_operator_editmesh_view3d(struct bContext *C); int ED_operator_editmesh_region_view3d(struct bContext *C); +int ED_operator_editmesh_or_editcurve_region_view3d(struct bContext *C); int ED_operator_editarmature(struct bContext *C); int ED_operator_editcurve(struct bContext *C); int ED_operator_editcurve_3d(struct bContext *C); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 43059d9af91..bf66439d834 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -150,8 +150,8 @@ void mesh_foreachScreenFace( void *userData, const eV3DProjTest clip_flag); void nurbs_foreachScreenVert( struct ViewContext *vc, - void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, - int beztindex, const float screen_co[2]), + void (*func)(struct ViewContext *vc, void *userData, struct Nurb *nu, struct BPoint *bp, + struct BezTriple *bezt, int beztindex, const float screen_co[2]), void *userData, const eV3DProjTest clip_flag); void mball_foreachScreenElem( struct ViewContext *vc, diff --git a/source/blender/editors/io/io_rhino_import.cpp b/source/blender/editors/io/io_rhino_import.cpp index 14b884ac69b..a50b923d7a7 100644 --- a/source/blender/editors/io/io_rhino_import.cpp +++ b/source/blender/editors/io/io_rhino_import.cpp @@ -88,7 +88,7 @@ static void import_ON_str(char *dest, ON_wString& onstr, size_t n) { // #define CU_NURB_ENDPOINT 2 // #define CU_NURB_BEZIER 4 static int analyze_knots(float *knots, int num_knots, int order, bool periodic, float tol=.001) { - printf("knots{"); for (int i=0; i<num_knots; i++) printf("%f,",knots[i]); printf("}->"); + // printf("knots{"); for (int i=0; i<num_knots; i++) printf("%f,",knots[i]); printf("}->"); float first = knots[1]; float last = knots[num_knots-2]; @@ -208,7 +208,6 @@ static void normalize_knots(Nurb *nu, char uv) { umin = std::min(umin,(float)new_uv); umax = std::max(umax,(float)new_uv); } - printf("[Knot (Trim Boudns) Bounds]: [%f (%f,%f) %f]\n",knots[0],umin,umax,knots[num_knots-1]); } } BKE_nurb_clear_cached_UV_mesh(nu,true); @@ -324,7 +323,6 @@ static Nurb *rhino_import_nurbscurve(bContext *C, ON_NurbsCurve *nc, ON_Object * editnurb = object_editcurve_get(obedit); BLI_addtail(editnurb, nu); ED_object_editmode_exit(C, EM_FREEDATA); - printf(" nurbscurve done\n"); return nu; } @@ -890,7 +888,7 @@ int rhino_import(bContext *C, wmOperator *op) { if (ON_Curve::Cast(Geometry)) { printf("--- Curve->%s \"%s\" ---\n",Object->ClassId()->ClassName(),obj_name); - rhino_import_curve(C, ON_Curve::Cast(Geometry), Object, &Attributes, false); + rhino_import_curve(C, ON_Curve::Cast(Geometry), Object, &Attributes, true); did_decode = true; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 23828098940..6cdf7a629d9 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -57,6 +57,7 @@ #include "ED_mesh.h" #include "ED_screen.h" #include "ED_view3d.h" +#include "ED_curve.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" @@ -1303,14 +1304,23 @@ static bool mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool de static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - + bool extend = RNA_boolean_get(op->ptr, "extend"); + bool deselect = RNA_boolean_get(op->ptr, "deselect"); + bool toggle = RNA_boolean_get(op->ptr, "toggle"); + + /* NURBS surfaces have their own loop selection code. */ + Object *obedit = CTX_data_edit_object(C); + if (ELEM(obedit->type, OB_CURVE, OB_SURF)) + { + int location[2]; + RNA_int_get_array(op->ptr, "location", location); + return mouse_nurb(C, location, extend, deselect, toggle, true); + } + /* end NURBS interception code */ + + bool b_ring = RNA_boolean_get(op->ptr, "ring"); view3d_operator_needs_opengl(C); - - if (mouse_mesh_loop(C, event->mval, - RNA_boolean_get(op->ptr, "extend"), - RNA_boolean_get(op->ptr, "deselect"), - RNA_boolean_get(op->ptr, "toggle"), - RNA_boolean_get(op->ptr, "ring"))) + if (mouse_mesh_loop(C, event->mval, extend, deselect, toggle, b_ring)) { return OPERATOR_FINISHED; } @@ -1328,7 +1338,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* api callbacks */ ot->invoke = edbm_select_loop_invoke; - ot->poll = ED_operator_editmesh_region_view3d; + ot->poll = ED_operator_editmesh_or_editcurve_region_view3d; /* flags */ ot->flag = OPTYPE_UNDO; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index eb79b0ca550..e9dbc409b53 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -363,6 +363,16 @@ int ED_operator_editmesh_region_view3d(bContext *C) return 0; } +int ED_operator_editmesh_or_editcurve_region_view3d(bContext *C) +{ + if (!CTX_wm_region_view3d(C)) return 0; + if (ED_operator_editmesh(C)) return 1; + if (ED_operator_editcurve(C)) return 1; + + CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editmesh/editcurve"); + return 0; +} + int ED_operator_editarmature(bContext *C) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index a2f7d9e7d6c..e5e6ca6f0bb 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -315,6 +315,10 @@ bool ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) return ret; } + + if (obedit && obedit->type == OB_CURVE) { + + } return 0; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 400e9348a61..b52a69e1907 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5915,7 +5915,9 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) case CU_NURBS: if (!sel && index == cu->actnu) { /* we should draw active spline highlight below everything */ - editnurb_draw_active_nurbs(nu); + /* DISABLED: it's painfully ugly *and* unnecessary given the color + * change that already highlights to the selected Nurb. */ + /* editnurb_draw_active_nurbs(nu); */ } bp = nu->bp; @@ -6016,7 +6018,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); - if (v3d->zbuf) glDepthFunc(GL_ALWAYS); + if (v3d->zbuf) glDepthFunc(GL_LEQUAL); /* first non-selected and active handles */ index = 0; @@ -6081,8 +6083,6 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } } } - - if (v3d->zbuf) glDepthFunc(GL_ALWAYS); for (nu = nurb; nu; nu = nu->next) { drawvertsN(nu, 1, hide_handles, vert); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 8e77892ada5..a030f03889a 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -418,7 +418,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } /* Curve... */ else if (totcurvedata == 1) { - uiDefButR(block, NUM, 0, IFACE_("Weight:"), 0, yi -= buth + but_margin, 200, buth, + uiDefButR(block, NUM, 0, IFACE_("SftBdy Weight:"), 0, yi -= buth + but_margin, 200, buth, &data_ptr, "weight_softbody", 0, 0.0, 1.0, 1, 3, NULL); uiDefButR(block, NUM, 0, IFACE_("Radius:"), 0, yi -= buth + but_margin, 200, buth, &data_ptr, "radius", 0, 0.0, 100.0, 1, 3, NULL); @@ -426,7 +426,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float &data_ptr, "tilt", 0, -tilt_limit, tilt_limit, 1, 3, NULL); } else if (totcurvedata > 1) { - uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Weight:"), + uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean SftBdy Weight:"), 0, yi -= buth + but_margin, 200, buth, &(tfp->ve_median[C_WEIGHT]), 0.0, 1.0, 1, 3, TIP_("Weight used for SoftBody Goal")); uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, IFACE_("Mean Radius:"), diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c index ce4b7f7deeb..5eee8f8d3d0 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.c +++ b/source/blender/editors/space_view3d/view3d_iterators.c @@ -269,7 +269,7 @@ void mesh_foreachScreenFace( void nurbs_foreachScreenVert( ViewContext *vc, - void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co_b[2]), + void (*func)(ViewContext *vc, void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co_b[2]), void *userData, const eV3DProjTest clip_flag) { Curve *cu = vc->obedit->data; @@ -295,24 +295,24 @@ void nurbs_foreachScreenVert( if (ED_view3d_project_float_object(vc->ar, bezt->vec[1], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { - func(userData, nu, NULL, bezt, 1, screen_co); + func(vc, userData, nu, NULL, bezt, 1, screen_co); } } else { if (ED_view3d_project_float_object(vc->ar, bezt->vec[0], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { - func(userData, nu, NULL, bezt, 0, screen_co); + func(vc, userData, nu, NULL, bezt, 0, screen_co); } if (ED_view3d_project_float_object(vc->ar, bezt->vec[1], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { - func(userData, nu, NULL, bezt, 1, screen_co); + func(vc, userData, nu, NULL, bezt, 1, screen_co); } if (ED_view3d_project_float_object(vc->ar, bezt->vec[2], screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { - func(userData, nu, NULL, bezt, 2, screen_co); + func(vc, userData, nu, NULL, bezt, 2, screen_co); } } } @@ -327,7 +327,7 @@ void nurbs_foreachScreenVert( if (ED_view3d_project_float_object(vc->ar, bp->vec, screen_co, V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK) { - func(userData, nu, bp, NULL, -1, screen_co); + func(vc, userData, nu, bp, NULL, -1, screen_co); } } } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 1f1317bde2c..7fdf0dfce90 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -533,7 +533,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m EDBM_selectmode_flush(vc->em); } -static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) +static void do_lasso_select_curve__doSelect(struct ViewContext* vc, void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) { LassoSelectUserData *data = userData; Object *obedit = data->vc->obedit; @@ -1706,7 +1706,7 @@ static int do_paintvert_box_select(ViewContext *vc, rcti *rect, bool select, boo return OPERATOR_FINISHED; } -static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) +static void do_nurbs_box_select__doSelect(struct ViewContext* vc, void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) { BoxSelectUserData *data = userData; Object *obedit = data->vc->obedit; @@ -2227,6 +2227,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) bool toggle = RNA_boolean_get(op->ptr, "toggle"); bool center = RNA_boolean_get(op->ptr, "center"); bool enumerate = RNA_boolean_get(op->ptr, "enumerate"); + bool alt = RNA_int_get(op->ptr, "alt"); /* only force object select for editmode to support vertex parenting, * or paint-select to allow pose bone select with vert/face select */ bool object = (RNA_boolean_get(op->ptr, "object") && @@ -2260,7 +2261,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) else if (obedit->type == OB_LATTICE) retval = mouse_lattice(C, location, extend, deselect, toggle); else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) - retval = mouse_nurb(C, location, extend, deselect, toggle); + retval = mouse_nurb(C, location, extend, deselect, toggle, alt); else if (obedit->type == OB_MBALL) retval = mouse_mball(C, location, extend, deselect, toggle); else if (obedit->type == OB_FONT) @@ -2288,6 +2289,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { RNA_int_set_array(op->ptr, "location", event->mval); + RNA_int_set(op->ptr, "alt", event->alt); return view3d_select_exec(C, op); } @@ -2315,6 +2317,7 @@ void VIEW3D_OT_select(wmOperatorType *ot) RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting, in editmode used to extend object selection"); RNA_def_boolean(ot->srna, "enumerate", 0, "Enumerate", "List objects under the mouse (object mode only)"); RNA_def_boolean(ot->srna, "object", 0, "Object", "Use object selection (editmode only)"); + RNA_def_int(ot->srna, "alt", 0, 0, 10, "AltKey", "Invoked with Alt pressed (loop select mode).", 0, 10); prop = RNA_def_int_vector(ot->srna, "location", 2, NULL, INT_MIN, INT_MAX, "Location", "Mouse location", INT_MIN, INT_MAX); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -2477,7 +2480,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, const bool select, cons } -static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) +static void nurbscurve_circle_doSelect(struct ViewContext* vc, void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co[2]) { CircleSelectUserData *data = userData; Object *obedit = data->vc->obedit; |