From 75100d0b943b8718afa937de0f2b2ba169a7f9d3 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 13 Jan 2020 15:09:21 +0100 Subject: Fix T72648: Texture Paint color sampling always samples only 1st tile when using UDIMS A more generic approach might be considered in the future (I assume there are other operators around that need an update in shifting their uvs) though. Maniphest Tasks: T72648 Differential Revision: https://developer.blender.org/D6570 --- source/blender/editors/sculpt_paint/paint_utils.c | 26 +++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 4a1b329fce5..db22729e8b0 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -519,13 +519,20 @@ void paint_sample_color( } if (image) { - ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); - if (ibuf && ibuf->rect) { - float uv[2]; - float u, v; - imapaint_pick_uv(me_eval, scene, ob_eval, faceindex, mval, uv); - sample_success = true; - + float uv[2]; + float u, v; + ImageUser iuser; + BKE_imageuser_default(&iuser); + + imapaint_pick_uv(me_eval, scene, ob_eval, faceindex, mval, uv); + + if (image->source == IMA_SRC_TILED) { + float new_uv[2]; + iuser.tile = BKE_image_get_tile_from_pos(image, uv, new_uv, NULL); + u = new_uv[0]; + v = new_uv[1]; + } + else { u = fmodf(uv[0], 1.0f); v = fmodf(uv[1], 1.0f); @@ -535,6 +542,11 @@ void paint_sample_color( if (v < 0.0f) { v += 1.0f; } + } + + ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, NULL); + if (ibuf && ibuf->rect) { + sample_success = true; u = u * ibuf->x; v = v * ibuf->y; -- cgit v1.2.3