Add support for indirectly linked Geometry Nodes node trees

This commit is contained in:
Sybren A. Stüvel 2021-02-02 13:41:29 +01:00
parent e4bf2e8e35
commit 23dea91572
9 changed files with 29 additions and 2 deletions

View File

@ -9,6 +9,7 @@ changed functionality, fixed bugs).
- When creating a BAT pack, mapped network drives are no longer changed from a drive letter to UNC notation. For example, when mapping a share `\\SERVER\Share` to drive letter `S:\`, BAT will now keep referencing `S:\` instead of rewriting paths to `\\SERVER\Share`. - When creating a BAT pack, mapped network drives are no longer changed from a drive letter to UNC notation. For example, when mapping a share `\\SERVER\Share` to drive letter `S:\`, BAT will now keep referencing `S:\` instead of rewriting paths to `\\SERVER\Share`.
- Better handling of drive letters, and of paths that cross drive boundaries. - Better handling of drive letters, and of paths that cross drive boundaries.
- Better testing of Windows-specific cases when running the tests on Windows, and of POSIX-specific cases on other platforms. - Better testing of Windows-specific cases when running the tests on Windows, and of POSIX-specific cases on other platforms.
- Add support for Geometry Nodes modifier.
## Version 1.2 (2019-10-09) ## Version 1.2 (2019-10-09)

View File

@ -60,3 +60,11 @@ def sequencer_strips(sequence_editor: BlendFileBlock) \
sbase = sequence_editor.get_pointer((b'seqbase', b'first')) sbase = sequence_editor.get_pointer((b'seqbase', b'first'))
yield from iter_seqbase(sbase) yield from iter_seqbase(sbase)
def modifiers(object_block: BlendFileBlock) -> typing.Iterator[BlendFileBlock]:
"""Generator, yield the object's modifiers."""
# 'ob->modifiers[...]'
mods = object_block.get_pointer((b'modifiers', b'first'))
yield from listbase(mods, next_path=(b'modifier', b'next'))

View File

@ -47,6 +47,7 @@ eModifierType_WeightVGProximity = 38
eModifierType_Ocean = 39 eModifierType_Ocean = 39
eModifierType_MeshCache = 46 eModifierType_MeshCache = 46
eModifierType_MeshSequenceCache = 52 eModifierType_MeshSequenceCache = 52
eModifierType_Nodes = 57
# DNA_particle_types.h # DNA_particle_types.h
PART_DRAW_OB = 7 PART_DRAW_OB = 7

View File

@ -139,8 +139,7 @@ def object_block(block: blendfile.BlendFileBlock) -> typing.Iterator[result.Bloc
ctx = modifier_walkers.ModifierContext(owner=block) ctx = modifier_walkers.ModifierContext(owner=block)
# 'ob->modifiers[...].filepath' # 'ob->modifiers[...].filepath'
mods = block.get_pointer((b'modifiers', b'first')) for mod_idx, block_mod in enumerate(iterators.modifiers(block)):
for mod_idx, block_mod in enumerate(iterators.listbase(mods, next_path=(b'modifier', b'next'))):
block_name = b'%s.modifiers[%d]' % (block.id_name, mod_idx) block_name = b'%s.modifiers[%d]' % (block.id_name, mod_idx)
mod_type = block_mod[b'modifier', b'type'] mod_type = block_mod[b'modifier', b'type']
log.debug('Tracing modifier %s, type=%d', block_name.decode(), mod_type) log.debug('Tracing modifier %s, type=%d', block_name.decode(), mod_type)

View File

@ -224,6 +224,14 @@ def _expand_object(block: blendfile.BlendFileBlock):
for psystem in iterators.listbase(psystems): for psystem in iterators.listbase(psystems):
yield psystem.get_pointer(b'part') yield psystem.get_pointer(b'part')
# Modifiers can also refer to other datablocks, which should also get expanded.
for block_mod in iterators.modifiers(block):
mod_type = block_mod[b'modifier', b'type']
# Currently only node groups are supported. If the support should expand
# to more types, something more intelligent than this should be made.
if mod_type == cdefs.eModifierType_Nodes:
yield block_mod.get_pointer(b'node_group')
@dna_code('PA') @dna_code('PA')
def _expand_particle_settings(block: blendfile.BlendFileBlock): def _expand_particle_settings(block: blendfile.BlendFileBlock):

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -255,6 +255,16 @@ class DepsTest(AbstractTracerTest):
# b'//textures/Textures/Buildings/buildings_roof_04-color.png', False), # b'//textures/Textures/Buildings/buildings_roof_04-color.png', False),
}) })
def test_geometry_nodes(self):
self.assert_deps('geometry-nodes/file_to_pack.blend', {
b'LInode_lib.blend': Expect(
type='Library', full_field='name[1024]', dirname_field=None,
basename_field=None, asset_path=b'//node_lib.blend', is_sequence=False),
b'LIobject_lib.blend': Expect(
type='Library', full_field='name[1024]', dirname_field=None,
basename_field=None, asset_path=b'//object_lib.blend', is_sequence=False),
})
def test_usage_abspath(self): def test_usage_abspath(self):
deps = [dep for dep in trace.deps(self.blendfiles / 'doubly_linked.blend') deps = [dep for dep in trace.deps(self.blendfiles / 'doubly_linked.blend')
if dep.asset_path == b'//material_textures.blend'] if dep.asset_path == b'//material_textures.blend']