diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-26 23:20:33 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-26 23:20:33 +0400 |
commit | de4eeb96946943289ac898525f09fc9c7afd4157 (patch) | |
tree | 5887eac0f56db6ce226a25ae34eaaa1169c7ee3a /source/blender/editors/space_view3d/view3d_select.c | |
parent | ce90b472afbe4f90af60e19a0a6cc6704d3a3549 (diff) | |
parent | 4514a4455be89bc0a789d78355321abe6cfd5112 (diff) |
svn merge ^/trunk/blender -r43693:43733
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 98 |
1 files changed, 58 insertions, 40 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 80fd404772e..ee3c0ee8234 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -248,6 +248,12 @@ static void EDBM_backbuf_checkAndSelectTFaces(Mesh *me, int select) /* *********************** GESTURE AND LASSO ******************* */ +typedef struct LassoSelectUserData { + ViewContext *vc; + rcti *rect; + int (*mcords)[2], moves, select, pass, done; +} LassoSelectUserData; + static int view3d_selectable_data(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -464,43 +470,43 @@ static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves) static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; + LassoSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { - BM_Select(data->vc.em->bm, eve, data->select); + BM_Select(data->vc->em->bm, eve, data->select); } } static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; + LassoSelectUserData *data = userData; if (EDBM_check_backbuf(bm_solidoffs+index)) { if (data->pass==0) { if ( edge_fully_inside_rect(data->rect, x0, y0, x1, y1) && lasso_inside(data->mcords, data->moves, x0, y0) && lasso_inside(data->mcords, data->moves, x1, y1)) { - BM_Select(data->vc.em->bm, eed, data->select); + BM_Select(data->vc->em->bm, eed, data->select); data->done = 1; } } else { if (lasso_inside_edge(data->mcords, data->moves, x0, y0, x1, y1)) { - BM_Select(data->vc.em->bm, eed, data->select); + BM_Select(data->vc->em->bm, eed, data->select); } } } } static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; + LassoSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { - BM_Select(data->vc.em->bm, efa, data->select); + BM_Select(data->vc->em->bm, efa, data->select); } } static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } data; + LassoSelectUserData data; ToolSettings *ts= vc->scene->toolsettings; rcti rect; int bbsel; @@ -510,7 +516,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, /* set editmesh */ vc->em= ((Mesh *)vc->obedit->data)->edit_btmesh; - data.vc= *vc; + data.vc= vc; data.rect = ▭ data.mcords = mcords; data.moves = moves; @@ -618,7 +624,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } *data = userData; + LassoSelectUserData *data = userData; Object *obedit= data->vc->obedit; Curve *cu= (Curve*)obedit->data; @@ -647,7 +653,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } data; + LassoSelectUserData data; /* set vc->editnurb */ data.vc = vc; @@ -664,7 +670,7 @@ static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, int y) { - struct { int (*mcords)[2]; short moves; short select; } *data = userData; + LassoSelectUserData *data = userData; if (lasso_inside(data->mcords, data->moves, x, y)) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); @@ -672,7 +678,7 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, } static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { int (*mcords)[2]; short moves; short select; } data; + LassoSelectUserData data; /* set editdata in vc */ data.mcords = mcords; @@ -1632,6 +1638,11 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* ******************** border and circle ************************************** */ +typedef struct BoxSelectUserData { + ViewContext *vc; + rcti *rect; + int select, pass, done; +} BoxSelectUserData; int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2) { @@ -1657,7 +1668,7 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext *vc; rcti *rect; int select; } *data = userData; + BoxSelectUserData *data = userData; Object *obedit= data->vc->obedit; Curve *cu= (Curve*)obedit->data; @@ -1685,7 +1696,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi } static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - struct { ViewContext *vc; rcti *rect; int select; } data; + BoxSelectUserData data; data.vc = vc; data.rect = rect; @@ -1702,7 +1713,7 @@ static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int exte static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, int y) { - struct { ViewContext vc; rcti *rect; int select; } *data = userData; + BoxSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y)) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); @@ -1710,9 +1721,9 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i } static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - struct { ViewContext vc; rcti *rect; int select, pass, done; } data; + BoxSelectUserData data; - data.vc= *vc; + data.vc= vc; data.rect = rect; data.select = select; @@ -1727,44 +1738,44 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int ex static void do_mesh_box_select__doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData; + BoxSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y)) { - BM_Select(data->vc.em->bm, eve, data->select); + BM_Select(data->vc->em->bm, eve, data->select); } } static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int index) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData; + BoxSelectUserData *data = userData; if(EDBM_check_backbuf(bm_solidoffs+index)) { if (data->pass==0) { if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1)) { - BM_Select(data->vc.em->bm, eed, data->select); + BM_Select(data->vc->em->bm, eed, data->select); data->done = 1; } } else { if (edge_inside_rect(data->rect, x0, y0, x1, y1)) { - BM_Select(data->vc.em->bm, eed, data->select); + BM_Select(data->vc->em->bm, eed, data->select); } } } } static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData; + BoxSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y)) { - BM_Select(data->vc.em->bm, efa, data->select); + BM_Select(data->vc->em->bm, efa, data->select); } } static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } data; + BoxSelectUserData data; ToolSettings *ts= vc->scene->toolsettings; int bbsel; - data.vc= *vc; + data.vc= vc; data.rect = rect; data.select = select; data.pass = 0; @@ -2259,9 +2270,16 @@ void VIEW3D_OT_select(wmOperatorType *ot) /* -------------------- circle select --------------------------------------------- */ +typedef struct CircleSelectUserData { + ViewContext *vc; + short select; + int mval[2]; + float radius; +} CircleSelectUserData; + static void mesh_circle_doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2271,7 +2289,7 @@ static void mesh_circle_doSelectVert(void *userData, BMVert *eve, int x, int y, } static void mesh_circle_doSelectEdge(void *userData, BMEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index)) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; if (edge_inside_circle(data->mval[0], data->mval[1], (short) data->radius, x0, y0, x1, y1)) { BM_Select(data->vc->em->bm, eed, data->select); @@ -2279,7 +2297,7 @@ static void mesh_circle_doSelectEdge(void *userData, BMEdge *eed, int x0, int y0 } static void mesh_circle_doSelectFace(void *userData, BMFace *efa, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2292,7 +2310,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f { ToolSettings *ts= vc->scene->toolsettings; int bbsel; - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; bbsel= EDBM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -2354,7 +2372,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m Object *ob= vc->obact; Mesh *me = ob?ob->data:NULL; /* int bbsel; */ /* UNUSED */ - /* struct {ViewContext *vc; short select; int mval[2]; float radius; } data = {NULL}; */ /* UNUSED */ + /* CircleSelectUserData data = {NULL}; */ /* UNUSED */ if (me) { bm_vertoffs= me->totvert+1; /* max index array */ @@ -2369,7 +2387,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *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; @@ -2400,7 +2418,7 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint } static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; /* set vc-> edit data */ @@ -2417,7 +2435,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int y) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2427,7 +2445,7 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int } static void lattice_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; /* set vc-> edit data */ @@ -2444,7 +2462,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2] // NOTE: pose-bone case is copied from editbone case... static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2459,7 +2477,7 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int } static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; bArmature *arm = vc->obact->data; bPose *pose = vc->obact->pose; bPoseChannel *pchan; @@ -2509,7 +2527,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2532,7 +2550,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int } static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + CircleSelectUserData data; bArmature *arm= vc->obedit->data; EditBone *ebone; int change= FALSE; |