diff options
author | Jeroen Bakker <jeroen@blender.org> | 2019-12-10 17:18:16 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2019-12-11 18:58:14 +0300 |
commit | 7878adf49cfff6ccbb18203f21c6355a518b34db (patch) | |
tree | 8f54eacad26647c6bd6db0b665ea4ff8063ab2ec /source/blender/editors | |
parent | 61e0e936441828c148b701c9a942d2ab6d9fe3a9 (diff) |
DrawManager: Disable Clipping in material/rendered mode
Viewport: Disable Clipping For EEVEE and External Renderers
Currently it is possible that, when using viewport clipping, the display and tools communicate
different information to the user then the renderer does. The reason is
that the renderer does not support viewport clipping. Both EEVEE and
Cycles do not support it.
This patch will disable the clipping in all the tools and drawing code
when the viewport drawing mode is `Material Preview` or `Rendered`.
This patch introduces a `RV3D_CLIPPING_ENABLED` util that checks if
clipping is enabled for the given `rv3d` and `v3d`. Also in places where
it was needed we added the `ViewContext` as a carrier for the `View3D`
and `RegionView3D`.
There are a few areas in the tooling (select, projection painting) that
still needs to be tackled after this patch.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D6047
Diffstat (limited to 'source/blender/editors')
6 files changed, 18 insertions, 14 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 1adbbe30286..4c4aa4214b2 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1460,7 +1460,8 @@ static bool point_is_visible(KnifeTool_OpData *kcd, BMFace *f_hit; /* If box clipping on, make sure p is not clipped */ - if (kcd->vc.rv3d->rflag & RV3D_CLIPPING && ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) { + if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d) && + ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) { return false; } @@ -1484,7 +1485,7 @@ static bool point_is_visible(KnifeTool_OpData *kcd, dist = kcd->vc.v3d->clip_end * 2.0f; } - if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { float view_clip[2][3]; /* note: view_clip[0] should never get clipped */ copy_v3_v3(view_clip[0], p_ofs); @@ -1935,7 +1936,7 @@ static int knife_sample_screen_density(KnifeTool_OpData *kcd, const float radius dis_sq = len_squared_v2v2(kfv->sco, sco); if (dis_sq < radius_sq) { - if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { c++; } @@ -2045,7 +2046,7 @@ static KnifeEdge *knife_find_closest_edge( /* now we have 'lambda' calculated (in screen-space) */ knife_interp_v3_v3v3(kcd, test_cagep, kfe->v1->cageco, kfe->v2->cageco, lambda); - if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { /* check we're in the view */ if (ED_view3d_clipping_test(kcd->vc.rv3d, test_cagep, true)) { continue; @@ -2152,7 +2153,7 @@ static KnifeVert *knife_find_closest_vert( dis_sq = len_squared_v2v2(kfv->sco, sco); if (dis_sq < curdis_sq && dis_sq < maxdist_sq) { - if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(kcd->vc.v3d, kcd->vc.rv3d)) { if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { curv = kfv; curdis_sq = dis_sq; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 510d734451b..c57490041bc 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -887,7 +887,7 @@ static bool project_bucket_point_occluded(const ProjPaintState *ps, const float pixelScreenCo[4]) { int isect_ret; - const bool do_clip = ps->rv3d ? (ps->rv3d->rflag & RV3D_CLIPPING) != 0 : 0; + const bool do_clip = RV3D_CLIPPING_ENABLED(ps->v3d, ps->rv3d); /* we could return 0 for 1 face buckets, as long as this function assumes * that the point its testing is only every originated from an existing face */ @@ -3024,7 +3024,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const bool is_ortho = ps->is_ortho; const bool is_flip_object = ps->is_flip_object; const bool do_backfacecull = ps->do_backfacecull; - const bool do_clip = ps->rv3d ? ps->rv3d->rflag & RV3D_CLIPPING : 0; + const bool do_clip = RV3D_CLIPPING_ENABLED(ps->v3d, ps->rv3d); vCo[0] = ps->mvert_eval[lt_vtri[0]].co; vCo[1] = ps->mvert_eval[lt_vtri[1]].co; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index f813be7d0a2..b26d706bbf4 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1013,6 +1013,7 @@ void ED_sculpt_redraw_planes_get(float planes[4][4], ARegion *ar, Object *ob) void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test) { RegionView3D *rv3d = ss->cache ? ss->cache->vc->rv3d : ss->rv3d; + View3D *v3d = ss->cache ? ss->cache->vc->v3d : ss->v3d; test->radius_squared = ss->cache ? ss->cache->radius_squared : ss->cursor_radius * ss->cursor_radius; @@ -1033,7 +1034,7 @@ void sculpt_brush_test_init(SculptSession *ss, SculptBrushTest *test) test->mirror_symmetry_pass = ss->cache ? ss->cache->mirror_symmetry_pass : 0; - if (rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) { test->clip_rv3d = rv3d; } else { @@ -6896,6 +6897,7 @@ static float sculpt_raycast_init(ViewContext *vc, float dist; Object *ob = vc->obact; RegionView3D *rv3d = vc->ar->regiondata; + View3D *v3d = vc->v3d; /* TODO: what if the segment is totally clipped? (return == 0) */ ED_view3d_win_to_segment_clipped( @@ -6910,7 +6912,7 @@ static float sculpt_raycast_init(ViewContext *vc, if ((rv3d->is_persp == false) && /* if the ray is clipped, don't adjust its start/end */ - ((rv3d->rflag & RV3D_CLIPPING) == 0)) { + RV3D_CLIPPING_ENABLED(v3d, rv3d)) { BKE_pbvh_raycast_project_ray_root(ob->sculpt->pbvh, original, ray_start, ray_end, ray_normal); /* recalculate the normal */ @@ -7005,6 +7007,7 @@ bool sculpt_cursor_geometry_info_update(bContext *C, copy_v3_v3(ss->cursor_normal, srd.face_normal); copy_v3_v3(ss->cursor_location, out->location); ss->rv3d = vc.rv3d; + ss->v3d = vc.v3d; if (!BKE_brush_use_locked_size(scene, brush)) { radius = paint_calc_object_space_radius(&vc, out->location, BKE_brush_size_get(scene, brush)); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6235f994272..061977d0c91 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -796,7 +796,7 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a GPU_clear(GPU_DEPTH_BIT); - if (rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) { ED_view3d_clipping_set(rv3d); } /* get surface depth without bias */ @@ -817,7 +817,7 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a WM_draw_region_viewport_unbind(ar); - if (rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(v3d, rv3d)) { ED_view3d_clipping_disable(); } rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED; diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 17b575cedae..38cb5ad8651 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -228,7 +228,7 @@ void ED_view3d_backbuf_depth_validate(ViewContext *vc) if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE_DEPSGRAPH) != 0)) { GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); - DRW_draw_depth_object(vc->ar, viewport, obact_eval); + DRW_draw_depth_object(vc->ar, vc->v3d, viewport, obact_eval); } vc->v3d->flag &= ~V3D_INVALID_BACKBUF; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index d7f7e96ba08..8b4012d6547 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1099,7 +1099,7 @@ int view3d_opengl_select(ViewContext *vc, GPU_depth_test(true); } - if (vc->rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(vc->v3d, vc->rv3d)) { ED_view3d_clipping_set(vc->rv3d); } @@ -1167,7 +1167,7 @@ int view3d_opengl_select(ViewContext *vc, GPU_depth_test(false); } - if (vc->rv3d->rflag & RV3D_CLIPPING) { + if (RV3D_CLIPPING_ENABLED(v3d, vc->rv3d)) { ED_view3d_clipping_disable(); } |