diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-04-30 08:48:40 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-04-30 08:48:40 +0400 |
commit | 16e7ed28be8e764437e5ad7fa1587c29f352def1 (patch) | |
tree | 2bed7e54fb8dd7b80ac5518a25ccaf66ab961458 /source/blender/editors/space_view3d/view3d_select.c | |
parent | 53dbc1efdfe26a6a4a6097559b8f65ffba92af48 (diff) |
Highlight last selected point in curve/surface edit mode.
Curve->lastselbp field was renamed to Curve->lastsel and now not last
either BPoint or BezTriple is storing here. It's not easy to determine
type of selected point, but operator which depends on such point reviews
the full nurbs, so this shouldn't be a problem.
Made changes to curve undo stuff to restore last selected point on undo/redo.
Added new theme color for curve last selected point.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 1414a51c6c9..2cad28b8d1e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -554,14 +554,15 @@ static void do_lasso_select_mesh_uv(short mcords[][2], short moves, short select static void do_lasso_select_curve__doSelect(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext vc; short (*mcords)[2]; short moves; short select; } *data = userData; - + struct { ViewContext *vc; short (*mcords)[2]; short moves; short select; } *data = userData; + Object *obedit= data->vc->obedit; + Curve *cu= (Curve*)obedit->data; + if (lasso_inside(data->mcords, data->moves, x, y)) { if (bp) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; } else { - Curve *cu= data->vc.obedit->data; - if (cu->drawflag & CU_HIDE_HANDLES) { /* can only be beztindex==0 here since handles are hidden */ bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); @@ -574,16 +575,18 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *nu, BPoint *bp bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT); } } + + if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel = NULL; } } } static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short moves, short select) { - struct { ViewContext vc; short (*mcords)[2]; short moves; short select; } data; + struct { ViewContext *vc; short (*mcords)[2]; short moves; short select; } data; /* set vc->editnurb */ - data.vc = *vc; + data.vc = vc; data.mcords = mcords; data.moves = moves; data.select = select; @@ -1274,14 +1277,15 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, static void do_nurbs_box_select__doSelect(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext vc; rcti *rect; int select; } *data = userData; + struct { ViewContext *vc; rcti *rect; int select; } *data = userData; + Object *obedit= data->vc->obedit; + Curve *cu= (Curve*)obedit->data; if (BLI_in_rcti(data->rect, x, y)) { if (bp) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; } else { - Curve *cu= data->vc.obedit->data; - if (cu->drawflag & CU_HIDE_HANDLES) { /* can only be beztindex==0 here since handles are hidden */ bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); @@ -1294,14 +1298,16 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *nu, BPoint *bp, bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT); } } + + if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel = NULL; } } } static void do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - struct { ViewContext vc; rcti *rect; int select; } data; + struct { ViewContext *vc; rcti *rect; int select; } data; - data.vc = *vc; + data.vc = vc; data.rect = rect; data.select = select; @@ -1871,18 +1877,29 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *nu, BPoint *bp, Bez struct {ViewContext *vc; short select, mval[2]; float radius; } *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); + Object *obedit= data->vc->obedit; + Curve *cu= (Curve*)obedit->data; if (r<=data->radius) { if (bp) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); + + if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; } else { - if (beztindex==0) { - bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT); - } else if (beztindex==1) { - bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + if (cu->drawflag & CU_HIDE_HANDLES) { + /* can only be beztindex==0 here since handles are hidden */ + bezt->f1 = bezt->f2 = bezt->f3 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); } else { - bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT); + if (beztindex==0) { + bezt->f1 = data->select?(bezt->f1|SELECT):(bezt->f1&~SELECT); + } else if (beztindex==1) { + bezt->f2 = data->select?(bezt->f2|SELECT):(bezt->f2&~SELECT); + } else { + bezt->f3 = data->select?(bezt->f3|SELECT):(bezt->f3&~SELECT); + } } + + if (bezt == cu->lastsel && !(bezt->f2 & 1)) cu->lastsel = NULL; } } } @@ -1896,6 +1913,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int selecting, short *mval data.mval[0] = mval[0]; data.mval[1] = mval[1]; data.radius = rad; + data.vc = vc; ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ nurbs_foreachScreenVert(vc, nurbscurve_circle_doSelect, &data); |