diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-20 07:08:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-20 07:08:56 +0300 |
commit | 15db2acd9fe1d64eb91d470813070df27cfc5698 (patch) | |
tree | 430fddf18aaa0cd6dba18a0546e4f926bcb81ffb /source/blender/draw/engines/eevee | |
parent | 720368e2d0f29e371807e09944170bb9222000e0 (diff) |
Fix T57722: Clipped LookDev preview spheres
D3948 by @pablodp606
Diffstat (limited to 'source/blender/draw/engines/eevee')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lookdev.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index a327759c1c8..e46526ce6af 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -164,6 +164,25 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata) RegionView3D *rv3d = draw_ctx->rv3d; ARegion *ar = draw_ctx->ar; + const float *viewport_size = DRW_viewport_size_get(); + rcti rect; + ED_region_visible_rect(draw_ctx->ar, &rect); + + const float viewport_size_target[2] = { + viewport_size[0] / 4, + viewport_size[1] / 4, + }; + const int viewport_inset[2] = { + max_ii(viewport_size_target[0], 300), + max_ii(viewport_size_target[0], 300) / 2, /* intentionally use 'x' here for 'y' value. */ + }; + + /* minimum size for preview spheres viewport */ + const float aspect[2] = { + viewport_inset[0] / viewport_size_target[0], + viewport_inset[1] / viewport_size_target[1], + }; + BKE_camera_params_from_view3d(¶ms, draw_ctx->depsgraph, v3d, rv3d); params.is_ortho = true; params.ortho_scale = 3.0f; @@ -174,15 +193,9 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata) params.shifty = 0.0f; params.clipsta = 0.001f; params.clipend = 20.0f; - BKE_camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); + BKE_camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, aspect[0], aspect[1]); BKE_camera_params_compute_matrix(¶ms); - const float *viewport_size = DRW_viewport_size_get(); - rcti rect; - ED_region_visible_rect(draw_ctx->ar, &rect); - int viewport_inset_x = viewport_size[0] / 4; - int viewport_inset_y = viewport_size[1] / 4; - EEVEE_CommonUniformBuffer *common = &sldata->common_data; common->la_num_light = 0; common->prb_num_planar = 0; @@ -211,12 +224,12 @@ void EEVEE_lookdev_draw_background(EEVEE_Data *vedata) GPUFrameBuffer *fb = effects->final_fb; GPU_framebuffer_bind(fb); - GPU_framebuffer_viewport_set(fb, rect.xmax - viewport_inset_x, rect.ymin, viewport_inset_x, viewport_inset_y); + GPU_framebuffer_viewport_set(fb, rect.xmax - viewport_inset[0], rect.ymin, viewport_inset[0], viewport_inset[1]); DRW_draw_pass(psl->lookdev_pass); fb = dfbl->depth_only_fb; GPU_framebuffer_bind(fb); - GPU_framebuffer_viewport_set(fb, rect.xmax - viewport_inset_x, rect.ymin, viewport_inset_x, viewport_inset_y); + GPU_framebuffer_viewport_set(fb, rect.xmax - viewport_inset[0], rect.ymin, viewport_inset[0], viewport_inset[1]); DRW_draw_pass(psl->lookdev_pass); DRW_viewport_matrix_override_unset_all(); |