diff options
author | Campbell Barton <campbell@blender.org> | 2022-07-22 06:05:26 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-07-22 06:07:24 +0300 |
commit | 08c5d99e88ee3e9f807dfe69c188660eae347f31 (patch) | |
tree | 7e4298800487b17a43c289462420507c35e4bb2b /source/blender/editors/uvedit | |
parent | 72e249974aa7f6a3bd6d5c35c5d5e59cd1c3bded (diff) |
Cleanup: add BKE_image_find_nearest_tile_with_offset
Every caller BKE_image_find_nearest_tile was calculating the tile offset
so add a version of this function that returns the offset too.
Diffstat (limited to 'source/blender/editors/uvedit')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_islands.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/source/blender/editors/uvedit/uvedit_islands.c b/source/blender/editors/uvedit/uvedit_islands.c index e1752ae5a29..9a31fd6469d 100644 --- a/source/blender/editors/uvedit/uvedit_islands.c +++ b/source/blender/editors/uvedit/uvedit_islands.c @@ -256,16 +256,12 @@ bool uv_coords_isect_udim(const Image *image, const int udim_grid[2], const floa * Calculates distance to nearest UDIM image tile in UV space and its UDIM tile number. */ static float uv_nearest_image_tile_distance(const Image *image, - float coords[2], + const float coords[2], float nearest_tile_co[2]) { - int nearest_image_tile_index = BKE_image_find_nearest_tile(image, coords); - if (nearest_image_tile_index == -1) { - nearest_image_tile_index = 1001; + if (BKE_image_find_nearest_tile_with_offset(image, coords, nearest_tile_co) == -1) { + zero_v2(nearest_tile_co); } - - nearest_tile_co[0] = (nearest_image_tile_index - 1001) % 10; - nearest_tile_co[1] = (nearest_image_tile_index - 1001) / 10; /* Add 0.5 to get tile center coordinates. */ float nearest_tile_center_co[2] = {nearest_tile_co[0], nearest_tile_co[1]}; add_v2_fl(nearest_tile_center_co, 0.5f); |