diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 0adf6633b05..dfe0a304748 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -265,6 +265,7 @@ struct ARegion *ED_view3d_context_region_unlock(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_gl(struct Object *ob, struct RegionView3D *rv3d); int ED_view3d_scene_layer_set(int lay, const int *values, int *active); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 391eecbbbae..35edd961b1e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5812,7 +5812,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* multiply view with object matrix. * 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 */ if((flag & DRAW_CONSTCOLOR) == 0) { diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index fb67e38cbf7..6833dec2e43 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -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->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 it work with duplis using displists, otherwise it will override the dupli-matrix */ glMultMatrixf(ob->obmat); - - /* initializes object space clipping, speeds up clip tests */ - ED_view3d_local_clipping(rv3d, ob->obmat); } /* ******************** default callbacks for view3d space ***************** */ diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 6391db7ae5e..9290e1fc631 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -485,11 +485,8 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, if (extend == 0 && select) EM_deselect_all(vc->em); - /* workaround: init mats first, EM_mask_init_backbuf_border can change - view matrix to pixel space, breaking edge select with backbuf. fixes bug [#20936] */ - - /* [#21018] breaks zbuf select. run below. only if bbsel fails */ - /* ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d) */ + /* for non zbuf projections, dont change the GL state */ + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); glLoadMatrixf(vc->rv3d->viewmat); 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 (bbsel) { 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); } } if(ts->selectmode & SCE_SELECT_EDGE) { - /* 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 */ - + /* Does both bbsel and non-bbsel versions (need screen cos for both) */ data.pass = 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 (bbsel) { 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); } } @@ -1491,12 +1486,8 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten if (extend == 0 && select) EM_deselect_all(vc->em); - /* workaround: init mats first, EM_mask_init_backbuf_border can change - view matrix to pixel space, breaking edge select with backbuf. fixes bug #20936 */ - /*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) */ + /* for non zbuf projections, dont change the GL state */ + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); glLoadMatrixf(vc->rv3d->viewmat); 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) { EM_backbuf_checkAndSelectVerts(vc->em, select); } else { - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); 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) { EM_backbuf_checkAndSelectFaces(vc->em, select); } else { - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data); } }