Support UDIM images

This commit is contained in:
Sybren A. Stüvel
2022-02-18 16:12:41 +01:00
parent 4ebd535b5f
commit 843c34c3c0
12 changed files with 51 additions and 4 deletions
+3 -1
View File
@@ -96,11 +96,13 @@ def image(block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]
cdefs.IMA_SRC_FILE,
cdefs.IMA_SRC_SEQUENCE,
cdefs.IMA_SRC_MOVIE,
cdefs.IMA_SRC_TILED,
}:
log.debug("skiping image source type %s", image_source)
return
pathname, field = block.get(b"name", return_field=True)
is_sequence = image_source == cdefs.IMA_SRC_SEQUENCE
is_sequence = image_source in {cdefs.IMA_SRC_SEQUENCE, cdefs.IMA_SRC_TILED}
yield result.BlockUsage(block, pathname, is_sequence, path_full_field=field)
+6 -1
View File
@@ -39,6 +39,12 @@ def expand_sequence(path: pathlib.Path) -> typing.Iterator[pathlib.Path]:
or the path of the first file in the sequence.
"""
if "<UDIM>" in path.name: # UDIM tiles
# Change <UDIM> marker to a glob pattern, then let the glob case handle it.
# This assumes that all files that match the glob are actually UDIM
# tiles; this could cause some false-positives.
path = path.with_name(path.name.replace('<UDIM>', '*'))
if "*" in str(path): # assume it is a glob
import glob
@@ -46,7 +52,6 @@ def expand_sequence(path: pathlib.Path) -> typing.Iterator[pathlib.Path]:
for fname in sorted(glob.glob(str(path), recursive=True)):
yield pathlib.Path(fname)
return
if not path.exists():
raise DoesNotExist(path)