diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-08-10 14:24:26 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-08-10 14:24:26 +0300 |
commit | b9898ebde44d6584ea37a05aaeca8760d31ccc7b (patch) | |
tree | e6dfc796cc82b4b8b8c248c4ff29d2e2047ff84c /source/blender/draw/modes/object_mode.c | |
parent | b17380971a144896b34b7863a82bbda3ff68a39f (diff) | |
parent | 553b581f25c1782c4231816965cd3f6ce58a449a (diff) |
Merge branch 'master' into filebrowser_redesign
Diffstat (limited to 'source/blender/draw/modes/object_mode.c')
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 8d4083f1723..87fc74f1f72 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -1115,6 +1115,10 @@ static void DRW_shgroup_camera_background_images(OBJECT_Shaders *sh_data, Object *ob, RegionView3D *rv3d) { + if (DRW_state_is_select()) { + return; + } + if (!BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d)) { return; } @@ -1250,9 +1254,9 @@ static void DRW_shgroup_camera_background_images(OBJECT_Shaders *sh_data, float camera_aspect_y = 1.0; float camera_offset_x = 0.0; float camera_offset_y = 0.0; - float camera_aspect = 1.0; float camera_width = size[0]; float camera_height = size[1]; + float camera_aspect = camera_width / camera_height; if (!DRW_state_is_image_render()) { rctf render_border; @@ -1280,48 +1284,52 @@ static void DRW_shgroup_camera_background_images(OBJECT_Shaders *sh_data, uv2img_space[0][0] = image_width; uv2img_space[1][1] = image_height; - img2cam_space[0][0] = (1.0 / image_width); - img2cam_space[1][1] = (1.0 / image_height); + const float fit_scale = image_aspect / camera_aspect; + img2cam_space[0][0] = 1.0 / image_width; + img2cam_space[1][1] = 1.0 / fit_scale / image_height; /* Update scaling based on image and camera framing */ float scale_x = bgpic->scale; float scale_y = bgpic->scale; if (bgpic->flag & CAM_BGIMG_FLAG_CAMERA_ASPECT) { - float fit_scale = image_aspect / camera_aspect; if (bgpic->flag & CAM_BGIMG_FLAG_CAMERA_CROP) { if (image_aspect > camera_aspect) { scale_x *= fit_scale; - } - else { - scale_y /= fit_scale; + scale_y *= fit_scale; } } else { if (image_aspect > camera_aspect) { + scale_x /= fit_scale; scale_y /= fit_scale; } else { scale_x *= fit_scale; + scale_y *= fit_scale; } } } + else { + /* Stretch image to camera aspect */ + scale_y /= 1.0 / fit_scale; + } // scale image to match the desired aspect ratio scale_m4[0][0] = scale_x; scale_m4[1][1] = scale_y; - /* Translate, using coordinates that aren't squashed by the aspect. */ - translate_m4[3][0] = bgpic->offset[0] * 2.0f * max_ff(1.0f, 1.0f / camera_aspect); - translate_m4[3][1] = bgpic->offset[1] * 2.0f * max_ff(1.0f, camera_aspect); + /* Translate */ + translate_m4[3][0] = image_width * bgpic->offset[0] * 2.0f; + translate_m4[3][1] = image_height * bgpic->offset[1] * 2.0f; mul_m4_series(bg_data->transform_mat, win_m4_translate, win_m4_scale, - translate_m4, img2cam_space, - scale_m4, + translate_m4, rot_m4, + scale_m4, uv2img_space); DRWPass *pass = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) ? psl->camera_images_front : @@ -2862,7 +2870,7 @@ static void DRW_shgroup_lightprobe(OBJECT_Shaders *sh_data, DRWCallBuffer *buf = buffer_theme_id_to_probe_cube_outline_shgrp( stl, theme_id, ob->base_flag); - /* TODO remove or change the drawing of the cube probes. Theses line draws nothing on purpose + /* TODO remove or change the drawing of the cube probes. This line draws nothing on purpose * to keep the call ids correct. */ zero_m4(probe_cube_mat); DRW_buffer_add_entry(buf, call_id, &draw_size, probe_cube_mat); |