Fix #131754: Out of bounds when drawing active UDIM tile.

There is a case where the active image index could be placed on an
non-existing tile. This PR fixes this by keeping track of the active
tile when looping over all tiles.

Pull Request: https://projects.blender.org/blender/blender/pulls/131789
This commit is contained in:
Jeroen Bakker
2024-12-12 12:29:06 +01:00
parent c22ade6993
commit d7c45e6e0c

View File

@@ -822,13 +822,20 @@ class MeshUVs : Overlay {
};
ListBaseWrapper<ImageTile> tiles(image->tiles);
/* image->active_tile_index could point to a non existing ImageTile. To work around this we
* get the active tile when looping over all tiles. */
const ImageTile *active_tile = nullptr;
int tile_index = 0;
for (const ImageTile *tile : tiles) {
draw_tile(tile, false);
if (tile_index == image->active_tile_index) {
active_tile = tile;
}
tile_index++;
}
/* Draw active tile on top. */
if (show_tiled_image_active_) {
draw_tile(tiles.get(image->active_tile_index), true);
if (show_tiled_image_active_ && active_tile != nullptr) {
draw_tile(active_tile, true);
}
}