示例#1
0
def _walk_point_cache(ctx: ModifierContext, block_name: bytes,
                      bfile: blendfile.BlendFile,
                      pointcache: blendfile.BlendFileBlock, extension: bytes):
    flag = pointcache[b'flag']
    if flag & cdefs.PTCACHE_EXTERNAL:
        path, field = pointcache.get(b'path', return_field=True)
        log.info('    external cache at %s', path)
        bpath = bpathlib.BlendPath(path)
        yield result.BlockUsage(pointcache,
                                bpath,
                                path_full_field=field,
                                is_sequence=True,
                                block_name=block_name)
    elif flag & cdefs.PTCACHE_DISK_CACHE:
        # See ptcache_path() in pointcache.c
        name, field = pointcache.get(b'name', return_field=True)
        if not name:
            # See ptcache_filename() in pointcache.c
            idname = ctx.owner[b'id', b'name']
            name = idname[2:].hex().upper().encode()
        path = b'//%b%b/%b_*%b' % (
            cdefs.PTCACHE_PATH, bfile.filepath.stem.encode(), name, extension)
        log.info('   disk cache at %s', path)
        bpath = bpathlib.BlendPath(path)
        yield result.BlockUsage(pointcache,
                                bpath,
                                path_full_field=field,
                                is_sequence=True,
                                block_name=block_name)
示例#2
0
def vector_font(
        block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]:
    """Vector Font data blocks."""
    path, field = block.get(b'name', return_field=True)
    if path == b'<builtin>':  # builtin font
        return
    yield result.BlockUsage(block, path, path_full_field=field)
示例#3
0
def modifier_filepath(ctx: ModifierContext, modifier: blendfile.BlendFileBlock, block_name: bytes) \
        -> typing.Iterator[result.BlockUsage]:
    """Just yield the 'filepath' field."""
    path, field = modifier.get(b'filepath', return_field=True)
    yield result.BlockUsage(modifier,
                            path,
                            path_full_field=field,
                            block_name=block_name)
示例#4
0
def image(
        block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]:
    """Image data blocks."""
    # old files miss this
    image_source = block.get(b'source', default=cdefs.IMA_SRC_FILE)
    if image_source not in {
            cdefs.IMA_SRC_FILE, cdefs.IMA_SRC_SEQUENCE, cdefs.IMA_SRC_MOVIE
    }:
        return

    pathname, field = block.get(b'name', return_field=True)
    is_sequence = image_source == cdefs.IMA_SRC_SEQUENCE

    yield result.BlockUsage(block,
                            pathname,
                            is_sequence,
                            path_full_field=field)
示例#5
0
def movie_clip(
        block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]:
    """MovieClip data blocks."""
    path, field = block.get(b'name', return_field=True)
    # TODO: The assumption that this is not a sequence may not be true for all modifiers.
    yield result.BlockUsage(block,
                            path,
                            is_sequence=False,
                            path_full_field=field)
示例#6
0
def modifier_ocean(ctx: ModifierContext, modifier: blendfile.BlendFileBlock, block_name: bytes) \
        -> typing.Iterator[result.BlockUsage]:
    if not modifier[b'cached']:
        return

    path, field = modifier.get(b'cachepath', return_field=True)
    # The path indicates the directory containing the cached files.
    yield result.BlockUsage(modifier,
                            path,
                            is_sequence=True,
                            path_full_field=field,
                            block_name=block_name)
示例#7
0
def cache_file(
        block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]:
    """Cache file data blocks."""
    path, field = block.get(b'filepath', return_field=True)
    yield result.BlockUsage(block, path, path_full_field=field)
示例#8
0
    def wrapper(block: blendfile.BlendFileBlock, *args, **kwargs):
        if block.get(b'packedfile', default=False):
            log.debug('Datablock %r is packed; skipping', block.id_name)
            return

        yield from wrapped(block, *args, **kwargs)
示例#9
0
def sound(
        block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]:
    """Sound data blocks."""
    path, field = block.get(b'name', return_field=True)
    yield result.BlockUsage(block, path, path_full_field=field)
示例#10
0
def _expand_generic_material(block: blendfile.BlendFileBlock):
    array_len = block.get(b'totcol')
    yield from block.iter_array_of_pointers(b'mat', array_len)