[Bf-blender-cvs] [279a67ecc8f] soc-2021-uv-editor-improvements: Minor fix : Correct calculation of nearest UDIM

Siddhartha Jejurkar noreply at git.blender.org
Fri Jun 11 17:27:04 CEST 2021


Commit: 279a67ecc8f012adb8b0485472048e096024edcf
Author: Siddhartha Jejurkar
Date:   Fri Jun 11 20:50:38 2021 +0530
Branches: soc-2021-uv-editor-improvements
https://developer.blender.org/rB279a67ecc8f012adb8b0485472048e096024edcf

Minor fix : Correct calculation of nearest UDIM

Corrects the logic for calculating the distance between selected UVs and
UDIM tiles

===================================================================

M	source/blender/blenkernel/intern/image.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 2f7e2b41a73..6db4b7b1dd9 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -748,13 +748,15 @@ int BKE_image_find_nearest_tile(const Image *image, const float co[2])
   LISTBASE_FOREACH (const ImageTile *, tile, &image->tiles) {
     const int tile_index = tile->tile_number - 1001;
     /* Coordinates of the current tile. */
-    const float tile_index_co[2] = {tile_index % 10, tile_index / 10};
+    float tile_index_co[2] = {tile_index % 10, tile_index / 10};
 
     if (equals_v2v2(co_floor, tile_index_co)) {
       return tile->tile_number;
     }
 
-    /* Distance between co[2] and UDIM tile. */
+    /* Distance between co[2] and center of UDIM tile. */
+    tile_index_co[0] += 0.5f;
+    tile_index_co[1] += 0.5f;
     const float dist_sq = len_squared_v2v2(tile_index_co, co);
 
     if (dist_sq < dist_best_sq) {



More information about the Bf-blender-cvs mailing list