Support Alembic files from linked library

We already supported Alembic files in the top-level blend file, but now we
also support finding Alembic files in linked-in libraries.
This commit is contained in:
Sybren A. Stüvel
2019-03-20 13:57:44 +01:00
parent c718fb3a41
commit 4964745dee
12 changed files with 42 additions and 3 deletions
+10 -1
View File
@@ -51,8 +51,17 @@ def deps(bfilepath: pathlib.Path, progress_cb: typing.Optional[progress.Callback
if progress_cb:
bi.progress_cb = progress_cb
# Remember which block usages we've reported already, without keeping the
# blocks themselves in memory.
seen_hashes = set() # type: typing.Set[int]
for block in asset_holding_blocks(bi.iter_blocks(bfile)):
yield from blocks2assets.iter_assets(block)
for block_usage in blocks2assets.iter_assets(block):
usage_hash = hash(block_usage)
if usage_hash in seen_hashes:
continue
seen_hashes.add(usage_hash)
yield block_usage
def asset_holding_blocks(blocks: typing.Iterable[blendfile.BlendFileBlock]) \
@@ -67,10 +67,17 @@ def modifier_mesh_sequence_cache(ctx: ModifierContext, modifier: blendfile.Blend
block_name: bytes) -> typing.Iterator[result.BlockUsage]:
"""Yield the Alembic file(s) used by this modifier"""
cache_file = modifier.get_pointer(b'cache_file')
path, field = cache_file.get(b'filepath', return_field=True)
if cache_file is None:
return
is_sequence = bool(cache_file[b'is_sequence'])
cache_block_name = cache_file.id_name
assert cache_block_name is not None
path, field = cache_file.get(b'filepath', return_field=True)
yield result.BlockUsage(cache_file, path, path_full_field=field,
block_name=b'%s.cache_file' % block_name)
is_sequence=is_sequence,
block_name=cache_block_name)
@mod_handler(cdefs.eModifierType_Ocean)