Blender 2.8 fixes because of removed Material.mtex and Material.group

This commit is contained in:
Sybren A. Stüvel 2018-06-07 15:18:18 +02:00
parent dfa07e19cc
commit 5f966934df
2 changed files with 12 additions and 1 deletions

View File

@ -148,6 +148,9 @@ class Struct:
"""
return self._fields
def has_field(self, field_name: bytes) -> bool:
return field_name in self._fields_by_name
def field_from_path(self,
pointer_size: int,
path: FieldPath) \

View File

@ -70,6 +70,10 @@ def _expand_generic_material(block: blendfile.BlendFileBlock):
def _expand_generic_mtex(block: blendfile.BlendFileBlock):
if not block.dna_type.has_field(b'mtex'):
# mtex was removed in Blender 2.8
return
for mtex in block.iter_fixed_array_of_pointers(b'mtex'):
yield mtex.get_pointer(b'tex')
yield mtex.get_pointer(b'object')
@ -137,7 +141,11 @@ def _expand_material(block: blendfile.BlendFileBlock):
yield from _expand_generic_nodetree_id(block)
yield from _expand_generic_mtex(block)
yield block.get_pointer(b'group')
try:
yield block.get_pointer(b'group')
except KeyError:
# Groups were removed from Blender 2.8
pass
@dna_code('MB')