diff options
author | Jesse Yurkovich <jesse.y@gmail.com> | 2022-05-28 08:11:52 +0300 |
---|---|---|
committer | Jesse Yurkovich <jesse.y@gmail.com> | 2022-05-28 08:11:52 +0300 |
commit | 86baf6e3edc8925c0701786550b2bac8fe5203d3 (patch) | |
tree | 872019c956476ca0e02a6fb1c27768bfb974aa10 /source/blender/blenkernel/intern | |
parent | 967f96ee2e2ed454034f3e6be53fc7259f9016d0 (diff) |
Re-fix T97366: Support single-file UDIMs
The original fix for T97366 was too restrictive and breaks real-world
cases of single-file UDIM textures. See D13297 for an example.
This patch effectively reverts the original fix and instead fixes the
downstream code to accept single-file ranges as necessary.
Note: This means it is very important for users to make use of the
"UDIM detection" option during `image.open` or drag n' drop scenarios in
order to declare their intent when loading their files.
Differential Revision: https://developer.blender.org/D14853
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/image.cc | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index dfa820519a5..4bf25c24235 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -2927,6 +2927,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) MEM_freeN(tile); } base_tile->next = nullptr; + base_tile->tile_number = 1001; ima->tiles.last = base_tile; } @@ -3108,7 +3109,9 @@ bool BKE_image_get_tile_info(char *filepath, ListBase *tiles, int *r_tile_start, char filename[FILE_MAXFILE], dirname[FILE_MAXDIR]; BLI_split_dirfile(filepath, dirname, filename, sizeof(dirname), sizeof(filename)); - BKE_image_ensure_tile_token(filename); + if (!BKE_image_is_filename_tokenized(filename)) { + BKE_image_ensure_tile_token(filename); + } eUDIM_TILE_FORMAT tile_format; char *udim_pattern = BKE_image_get_tile_strformat(filename, &tile_format); @@ -3142,10 +3145,7 @@ 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); - /* 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) { + if (all_valid_udim && min_udim <= IMA_UDIM_MAX) { BLI_join_dirfile(filepath, FILE_MAX, dirname, filename); *r_tile_start = min_udim; @@ -3317,13 +3317,18 @@ bool BKE_image_fill_tile(struct Image *ima, return false; } +bool BKE_image_is_filename_tokenized(char *filepath) +{ + const char *filename = BLI_path_basename(filepath); + return strstr(filename, "<UDIM>") != nullptr || strstr(filename, "<UVTILE>") != nullptr; +} + void BKE_image_ensure_tile_token(char *filename) { BLI_assert_msg(BLI_path_slash_find(filename) == nullptr, "Only the file-name component should be used!"); - /* Is there a '<' character in the filename? Assume tokens already present. */ - if (strstr(filename, "<") != nullptr) { + if (BKE_image_is_filename_tokenized(filename)) { return; } |