diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-03-18 16:16:39 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-03-18 16:17:19 +0300 |
commit | fe9e7036b00716d8ac986db5b9f832ec80d0a62b (patch) | |
tree | 673c300d917d65fe25271b4fe63f48479e93cf7f | |
parent | 65b8b387873cec58974dd59be2b5f0a70027077d (diff) |
Fix UV's not aligning with image.
This reverts a part of {rB33409f9f1cd42e899f2706fe7878e5e89b50d617}.
-rw-r--r-- | source/blender/draw/engines/image/image_space_image.hh | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/source/blender/draw/engines/image/image_space_image.hh b/source/blender/draw/engines/image/image_space_image.hh index 7c15d780d07..264129e0728 100644 --- a/source/blender/draw/engines/image/image_space_image.hh +++ b/source/blender/draw/engines/image/image_space_image.hh @@ -152,25 +152,17 @@ class SpaceImageAccessor : public AbstractSpaceAccessor { const float image_resolution[2], float r_uv_to_texture[4][4]) const override { - float zoom_x = image_resolution[0] * sima->zoom; - float zoom_y = image_resolution[1] * sima ->zoom; - float image_offset_x = (region->winx - zoom_x) / 2 + sima->xof + image_display_offset[0]; - float image_offset_y = (region->winy - zoom_y) / 2 + sima->yof + image_display_offset[1]; - - unit_m4(r_uv_to_texture); - float scale_x = 1.0 / BLI_rctf_size_x(®ion->v2d.cur); - float scale_y = 1.0 / BLI_rctf_size_y(®ion->v2d.cur); - float offset_x = 1.0 / image_resolution[0] * image_offset_x; - float offset_y = 1.0 / image_resolution[1] * image_offset_y; - - float translate_x = scale_x * (-region->v2d.cur.xmin + offset_x); - float translate_y = scale_y * (-region->v2d.cur.ymin + offset_y); - - r_uv_to_texture[0][0] = scale_x; - r_uv_to_texture[1][1] = scale_y; - r_uv_to_texture[3][0] = translate_x; - r_uv_to_texture[3][1] = translate_y; - } + unit_m4(r_uv_to_texture); + float scale_x = 1.0 / BLI_rctf_size_x(®ion->v2d.cur); + float scale_y = 1.0 / BLI_rctf_size_y(®ion->v2d.cur); + float translate_x = scale_x * -region->v2d.cur.xmin; + float translate_y = scale_y * -region->v2d.cur.ymin; + + r_uv_to_texture[0][0] = scale_x; + r_uv_to_texture[1][1] = scale_y; + r_uv_to_texture[3][0] = translate_x; + r_uv_to_texture[3][1] = translate_y; + } }; } // namespace blender::draw::image_engine |