[#27615] Box select of mesh object disabled or translated due to curve object

ED_view3d_init_mats_rv3d was calling glMultMatrixf() which was mostly harmless but could also lead to confusing bugs (2 reported previously).
Looked into this and every call to ED_view3d_init_mats_rv3d except for object drawing, doesn't need this so made a second version of ED_view3d_init_mats_rv3d - ED_view3d_init_mats_rv3d_gl which does the matrix multiplication, remove confusing checks in selection code.
This commit is contained in:
Campbell Barton 2011-06-09 03:56:32 +00:00
parent e7e1bc4ca1
commit 912db4cdb5
4 changed files with 19 additions and 24 deletions

@ -265,6 +265,7 @@ struct ARegion *ED_view3d_context_region_unlock(struct bContext *C);
int ED_operator_rv3d_unlock_poll(struct bContext *C); int ED_operator_rv3d_unlock_poll(struct bContext *C);
void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d); void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d);
void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d);
int ED_view3d_scene_layer_set(int lay, const int *values, int *active); int ED_view3d_scene_layer_set(int lay, const int *values, int *active);

@ -5812,7 +5812,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
/* multiply view with object matrix. /* multiply view with object matrix.
* local viewmat and persmat, to calculate projections */ * local viewmat and persmat, to calculate projections */
ED_view3d_init_mats_rv3d(ob, rv3d); ED_view3d_init_mats_rv3d_gl(ob, rv3d);
/* which wire color */ /* which wire color */
if((flag & DRAW_CONSTCOLOR) == 0) { if((flag & DRAW_CONSTCOLOR) == 0) {

@ -208,13 +208,18 @@ void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d)
mul_m4_m4m4(rv3d->viewmatob, ob->obmat, rv3d->viewmat); mul_m4_m4m4(rv3d->viewmatob, ob->obmat, rv3d->viewmat);
mul_m4_m4m4(rv3d->persmatob, ob->obmat, rv3d->persmat); mul_m4_m4m4(rv3d->persmatob, ob->obmat, rv3d->persmat);
/* initializes object space clipping, speeds up clip tests */
ED_view3d_local_clipping(rv3d, ob->obmat);
}
void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d)
{
ED_view3d_init_mats_rv3d(ob, rv3d);
/* we have to multiply instead of loading viewmatob to make /* we have to multiply instead of loading viewmatob to make
it work with duplis using displists, otherwise it will it work with duplis using displists, otherwise it will
override the dupli-matrix */ override the dupli-matrix */
glMultMatrixf(ob->obmat); glMultMatrixf(ob->obmat);
/* initializes object space clipping, speeds up clip tests */
ED_view3d_local_clipping(rv3d, ob->obmat);
} }
/* ******************** default callbacks for view3d space ***************** */ /* ******************** default callbacks for view3d space ***************** */

@ -485,11 +485,8 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves,
if (extend == 0 && select) if (extend == 0 && select)
EM_deselect_all(vc->em); EM_deselect_all(vc->em);
/* workaround: init mats first, EM_mask_init_backbuf_border can change /* for non zbuf projections, dont change the GL state */
view matrix to pixel space, breaking edge select with backbuf. fixes bug [#20936] */ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
/* [#21018] breaks zbuf select. run below. only if bbsel fails */
/* ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d) */
glLoadMatrixf(vc->rv3d->viewmat); glLoadMatrixf(vc->rv3d->viewmat);
bbsel= EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); bbsel= EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
@ -497,15 +494,13 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves,
if(ts->selectmode & SCE_SELECT_VERTEX) { if(ts->selectmode & SCE_SELECT_VERTEX) {
if (bbsel) { if (bbsel) {
EM_backbuf_checkAndSelectVerts(vc->em, select); EM_backbuf_checkAndSelectVerts(vc->em, select);
} else { }
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ else {
mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, 1); mesh_foreachScreenVert(vc, do_lasso_select_mesh__doSelectVert, &data, 1);
} }
} }
if(ts->selectmode & SCE_SELECT_EDGE) { if(ts->selectmode & SCE_SELECT_EDGE) {
/* Does both bbsel and non-bbsel versions (need screen cos for both) */ /* Does both bbsel and non-bbsel versions (need screen cos for both) */
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
data.pass = 0; data.pass = 0;
mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, 0); mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, 0);
@ -518,8 +513,8 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves,
if(ts->selectmode & SCE_SELECT_FACE) { if(ts->selectmode & SCE_SELECT_FACE) {
if (bbsel) { if (bbsel) {
EM_backbuf_checkAndSelectFaces(vc->em, select); EM_backbuf_checkAndSelectFaces(vc->em, select);
} else { }
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ else {
mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data); mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data);
} }
} }
@ -1491,12 +1486,8 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
if (extend == 0 && select) if (extend == 0 && select)
EM_deselect_all(vc->em); EM_deselect_all(vc->em);
/* workaround: init mats first, EM_mask_init_backbuf_border can change /* for non zbuf projections, dont change the GL state */
view matrix to pixel space, breaking edge select with backbuf. fixes bug #20936 */ ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
/*ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);*/ /* for foreach's screen/vert projection */
/* [#21018] breaks zbuf select. run below. only if bbsel fails */
/* ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d) */
glLoadMatrixf(vc->rv3d->viewmat); glLoadMatrixf(vc->rv3d->viewmat);
bbsel= EM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax); bbsel= EM_init_backbuf_border(vc, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
@ -1505,7 +1496,6 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
if (bbsel) { if (bbsel) {
EM_backbuf_checkAndSelectVerts(vc->em, select); EM_backbuf_checkAndSelectVerts(vc->em, select);
} else { } else {
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, 1); mesh_foreachScreenVert(vc, do_mesh_box_select__doSelectVert, &data, 1);
} }
} }
@ -1525,7 +1515,6 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten
if(bbsel) { if(bbsel) {
EM_backbuf_checkAndSelectFaces(vc->em, select); EM_backbuf_checkAndSelectFaces(vc->em, select);
} else { } else {
ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d);
mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data); mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data);
} }
} }