diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-05-09 20:21:22 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-05-10 13:21:51 +0300 |
commit | d2f1f80a6fa46614255e9cdc69795c7bcf368b7c (patch) | |
tree | a253f56bc00f13b66933b4efa0afcee9eb78c3ba /source/blender/editors | |
parent | 9395646c2c44cdf568ca950700d71fe966f2d80f (diff) |
Partial fix to Multi-View single eye issues in viewport
Handling depth loop for now (3d cursor positioning). Selection is a bit
more tricky.
Reported on 51354
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 83 |
2 files changed, 48 insertions, 36 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 9ce71258573..74041de019b 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -356,6 +356,7 @@ void ED_view3d_draw_offscreen( float winmat[4][4], bool do_bgpic, bool do_sky, bool is_persp, const char *viewname, struct GPUFX *fx, struct GPUFXSettings *fx_settings, struct GPUOffScreen *ofs); +void ED_view3d_draw_setup_view(struct wmWindow *win, struct Scene *scene, struct ARegion *ar, struct View3D *v3d); struct ImBuf *ED_view3d_draw_offscreen_imbuf( struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 8f2ea86f836..05f18a6771f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -105,6 +105,7 @@ #include "view3d_intern.h" /* own include */ /* prototypes */ +static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d); static void view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar); static void view3d_stereo3d_setup_offscreen(Scene *scene, View3D *v3d, ARegion *ar, float winmat[4][4], const char *viewname); @@ -2369,19 +2370,12 @@ float view3d_depth_near(ViewDepths *d) void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) { short zbuf = v3d->zbuf; - RegionView3D *rv3d = ar->regiondata; - - view3d_winmatrix_set(ar, v3d, NULL); - view3d_viewmatrix_set(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ - mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); - invert_m4_m4(rv3d->persinv, rv3d->persmat); - invert_m4_m4(rv3d->viewinv, rv3d->viewmat); + /* Setup view matrix. */ + ED_view3d_draw_setup_view(NULL, scene, ar, v3d); glClear(GL_DEPTH_BUFFER_BIT); - glLoadMatrixf(rv3d->viewmat); - v3d->zbuf = true; glEnable(GL_DEPTH_TEST); @@ -2390,7 +2384,6 @@ void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) } v3d->zbuf = zbuf; - } static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d) @@ -2489,17 +2482,11 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover U.glalphaclip = alphaoverride ? 0.5f : glalphaclip; /* not that nice but means we wont zoom into billboards */ U.obcenter_dia = 0; - view3d_winmatrix_set(ar, v3d, NULL); - view3d_viewmatrix_set(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ - - mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); - invert_m4_m4(rv3d->persinv, rv3d->persmat); - invert_m4_m4(rv3d->viewinv, rv3d->viewmat); + /* Setup view matrix. */ + ED_view3d_draw_setup_view(NULL, scene, ar, v3d); glClear(GL_DEPTH_BUFFER_BIT); - glLoadMatrixf(rv3d->viewmat); - if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(rv3d); } @@ -3265,6 +3252,22 @@ void ED_view3d_draw_offscreen( } /** + * Set the correct matrices + */ +void ED_view3d_draw_setup_view(wmWindow *win, Scene *scene, ARegion *ar, View3D *v3d) +{ + RegionView3D *rv3d = ar->regiondata; + + /* Setup the view matrix. */ + if (view3d_stereo3d_active(win, scene, v3d, rv3d)) { + view3d_stereo3d_setup(scene, v3d, ar); + } + else { + view3d_main_region_setup_view(scene, v3d, ar, NULL, NULL); + } +} + +/** * Utility func for ED_view3d_draw_offscreen * * \param ofs: Optional off-screen buffer, can be NULL. @@ -3698,26 +3701,37 @@ static void view3d_main_region_draw_engine_info(View3D *v3d, RegionView3D *rv3d, ED_region_info_draw(ar, rv3d->render_engine->text, fill_color, true); } -static bool view3d_stereo3d_active(const bContext *C, Scene *scene, View3D *v3d, RegionView3D *rv3d) +static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d) { - wmWindow *win = CTX_wm_window(C); - - if ((scene->r.scemode & R_MULTIVIEW) == 0) - return false; - - if (WM_stereo3d_enabled(win, true) == false) + if ((scene->r.scemode & R_MULTIVIEW) == 0) { return false; + } - if ((v3d->camera == NULL) || (v3d->camera->type != OB_CAMERA) || rv3d->persp != RV3D_CAMOB) + if ((v3d->camera == NULL) || (v3d->camera->type != OB_CAMERA) || rv3d->persp != RV3D_CAMOB) { return false; + } - if (scene->r.views_format & SCE_VIEWS_FORMAT_MULTIVIEW) { - if (v3d->stereo3d_camera == STEREO_MONO_ID) + switch (v3d->stereo3d_camera) { + case STEREO_MONO_ID: return false; - - return BKE_scene_multiview_is_stereo3d(&scene->r); + break; + case STEREO_3D_ID: + /* win will be NULL when calling this from the selection or draw loop. */ + if ((win == NULL) || (WM_stereo3d_enabled(win, true) == false)) { + return false; + } + if (((scene->r.views_format & SCE_VIEWS_FORMAT_MULTIVIEW) != 0) && + !BKE_scene_multiview_is_stereo3d(&scene->r)) + { + return false; + } + break; + /* We always need the stereo calculation for left and right cameras. */ + case STEREO_LEFT_ID: + case STEREO_RIGHT_ID: + default: + break; } - return true; } @@ -3830,11 +3844,8 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie GPU_default_lights(); } - /* setup the view matrix */ - if (view3d_stereo3d_active(C, scene, v3d, rv3d)) - view3d_stereo3d_setup(scene, v3d, ar); - else - view3d_main_region_setup_view(scene, v3d, ar, NULL, NULL); + /* Setup the view matrix. */ + ED_view3d_draw_setup_view(CTX_wm_window(C), scene, ar, v3d); rv3d->rflag &= ~RV3D_IS_GAME_ENGINE; #ifdef WITH_GAMEENGINE |