Fix 100035: Make UDIM detection less aggressive
There's been a handful of reports where "obviously" not a UDIM filenames were detected as such during image open.[1] This change makes the detection less aggressive by enforcing that the 4-digit sequence be delineated on both sides by one of the following 3 characters ., -, _ This fixes the problem for such filenames as: "screenshot-1080p.png", "Image-1920x1080.png", "(1999) Photo.png", and "antiguaChestnut_X_1240Wx814H.png" [1] T97366 T98918 T99154 T100035 Differential Revision: https://developer.blender.org/D15573
This commit is contained in:
parent
cfd16c04f8
commit
8ae14bc1d7
|
@ -3410,9 +3410,8 @@ void BKE_image_ensure_tile_token(char *filename)
|
|||
|
||||
/* General 4-digit "udim" pattern. As this format is susceptible to ambiguity
|
||||
* with other digit sequences, we can leverage the supported range of roughly
|
||||
* 1000 through 2000 to provide better detection.
|
||||
*/
|
||||
std::regex pattern(R"((^|.*?\D)([12]\d{3})(\D.*))");
|
||||
* 1000 through 2000 to provide better detection. */
|
||||
std::regex pattern(R"((.*[._-])([12]\d{3})([._-].*))");
|
||||
if (std::regex_search(path, match, pattern)) {
|
||||
BLI_strncpy(filename, match.format("$1<UDIM>$3").c_str(), FILE_MAX);
|
||||
return;
|
||||
|
|
|
@ -32,8 +32,12 @@ TEST(udim, image_ensure_tile_token)
|
|||
verify("test_1002_ao.png", "test_<UDIM>_ao.png");
|
||||
verify("test.1002.ver0023.png", "test.<UDIM>.ver0023.png");
|
||||
verify("test.ver0023.1002.png", "test.ver0023.<UDIM>.png");
|
||||
verify("1002test.png", "<UDIM>test.png");
|
||||
verify("test1002.png", "test<UDIM>.png");
|
||||
verify("test.1002.1.png", "test.<UDIM>.1.png");
|
||||
verify("test.1.1002.png", "test.1.<UDIM>.png");
|
||||
verify("test-2022-01-01.1002.png", "test-2022-01-01.<UDIM>.png");
|
||||
verify("1111_11.1002.png", "1111_11.<UDIM>.png");
|
||||
verify("2111_01.1002.png", "2111_01.<UDIM>.png");
|
||||
verify("2022_1002_100200.1002.png", "2022_1002_100200.<UDIM>.png");
|
||||
|
||||
/* UVTILE pattern detection. */
|
||||
verify("uv-test.u2_v10.png", "uv-test.<UVTILE>.png");
|
||||
|
@ -44,8 +48,15 @@ TEST(udim, image_ensure_tile_token)
|
|||
verify("u2_v10uv-test.png", "<UVTILE>uv-test.png");
|
||||
verify("u2_v10u_v-test.png", "<UVTILE>u_v-test.png");
|
||||
|
||||
/* Incorrect patterns. */
|
||||
for (const char *incorrect : {"test.123.png",
|
||||
/* Patterns which should not be detected as UDIMs. */
|
||||
for (const char *incorrect : {"1002.png",
|
||||
"1002test.png",
|
||||
"test1002.png",
|
||||
"test(1002).png",
|
||||
"(1002)test.png",
|
||||
"test-1080p.png",
|
||||
"test-1920x1080.png",
|
||||
"test.123.png",
|
||||
"test.12345.png",
|
||||
"test.uv.png",
|
||||
"test.u1v.png",
|
||||
|
|
Loading…
Reference in New Issue