Support nested collections in Blender 2.8
This commit is contained in:
parent
5f966934df
commit
f7a18ba07d
@ -123,10 +123,24 @@ def _expand_curve(block: blendfile.BlendFileBlock):
|
|||||||
|
|
||||||
@dna_code('GR')
|
@dna_code('GR')
|
||||||
def _expand_group(block: blendfile.BlendFileBlock):
|
def _expand_group(block: blendfile.BlendFileBlock):
|
||||||
|
log.debug('Block: %s', block)
|
||||||
|
|
||||||
objects = block.get_pointer((b'gobject', b'first'))
|
objects = block.get_pointer((b'gobject', b'first'))
|
||||||
for item in iterators.listbase(objects):
|
for item in iterators.listbase(objects):
|
||||||
yield item.get_pointer(b'ob')
|
yield item.get_pointer(b'ob')
|
||||||
|
|
||||||
|
# Recurse through child collections.
|
||||||
|
try:
|
||||||
|
children = block.get_pointer((b'children', b'first'))
|
||||||
|
except KeyError:
|
||||||
|
# 'children' was introduced in Blender 2.8 collections
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
for child in iterators.listbase(children):
|
||||||
|
subcoll = child.get_pointer(b'collection')
|
||||||
|
log.debug('recursing into child collection %s', subcoll.id_name)
|
||||||
|
yield from _expand_group(subcoll)
|
||||||
|
|
||||||
|
|
||||||
@dna_code('LA')
|
@dna_code('LA')
|
||||||
def _expand_lamp(block: blendfile.BlendFileBlock):
|
def _expand_lamp(block: blendfile.BlendFileBlock):
|
||||||
|
|||||||
@ -153,6 +153,10 @@ class BlockUsage:
|
|||||||
self._abspath = as_path.resolve()
|
self._abspath = as_path.resolve()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self._abspath = as_path
|
self._abspath = as_path
|
||||||
|
log.info('Resolving %s rel to %s → %s',
|
||||||
|
self.asset_path, self.block.bfile.filepath, self._abspath)
|
||||||
|
else:
|
||||||
|
log.info('Reusing abspath %s', self._abspath)
|
||||||
return self._abspath
|
return self._abspath
|
||||||
|
|
||||||
abspath = property(__fspath__)
|
abspath = property(__fspath__)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user