Fix T97366: Misdetection of numbers as UDIMs in certain filepaths

In some circumstances singular files with numbers in their name (like
turntable-1080p.png or frame-1042.png) might be detected as a UDIM.

The root cause in this particular instance was because `BKE_image_get_tile_info`
believed this file to be a tiled texture and replaced the filename with
a tokenized version of it. However, later on, the code inside `image_open_single`
did not believe it was tiled because only 1 file was detected and our
tiled textures require at least 2. This discrepancy lead to the broken
filename situation.

This was a regression since rB180b66ae8a1f as that introduced the
tokenization changes.

Differential Revision: https://developer.blender.org/D14667
This commit is contained in:
Jesse Yurkovich 2022-04-16 14:18:08 -07:00
parent 2b191cd2b4
commit 98eb111568
Notes: blender-bot 2023-02-14 05:22:18 +01:00
Referenced by issue #97366, Regression: Numbers are replaced in image file names with "<UDIM>" and fails to open them
1 changed files with 6 additions and 3 deletions

View File

@ -3106,7 +3106,7 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start,
eUDIM_TILE_FORMAT tile_format;
char *udim_pattern = BKE_image_get_tile_strformat(filename, &tile_format);
bool is_udim = true;
bool all_valid_udim = true;
int min_udim = IMA_UDIM_MAX + 1;
int max_udim = 0;
int id;
@ -3124,7 +3124,7 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start,
}
if (id < 1001 || id > IMA_UDIM_MAX) {
is_udim = false;
all_valid_udim = false;
break;
}
@ -3135,7 +3135,10 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start,
BLI_filelist_free(dirs, dirs_num);
MEM_SAFE_FREE(udim_pattern);
if (is_udim && min_udim <= IMA_UDIM_MAX) {
/* Ensure that all discovered UDIMs are valid and that there's at least 2 files in total.
* Downstream code checks the range value to determine tiled-ness; it's important we match that
* expectation here too (T97366). */
if (all_valid_udim && min_udim <= IMA_UDIM_MAX && max_udim > min_udim) {
BLI_join_dirfile(filepath, FILE_MAX, dirname, filename);
*r_tile_start = min_udim;