support for expanding more block types
This commit is contained in:
@@ -216,9 +216,18 @@ class FilePath:
|
|||||||
yield from fn(block, basedir, rootdir)
|
yield from fn(block, basedir, rootdir)
|
||||||
|
|
||||||
def _from_block_IM(block, basedir, rootdir):
|
def _from_block_IM(block, basedir, rootdir):
|
||||||
|
# (IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)
|
||||||
|
if block[b'source'] not in {1, 2, 3}:
|
||||||
|
return
|
||||||
|
if block[b'packedfile']:
|
||||||
|
return
|
||||||
|
|
||||||
yield FilePath(block, b'name', basedir), rootdir
|
yield FilePath(block, b'name', basedir), rootdir
|
||||||
|
|
||||||
def _from_block_LI(block, basedir, rootdir):
|
def _from_block_LI(block, basedir, rootdir):
|
||||||
|
if block[b'packedfile']:
|
||||||
|
return
|
||||||
|
|
||||||
yield FilePath(block, b'name', basedir), rootdir
|
yield FilePath(block, b'name', basedir), rootdir
|
||||||
|
|
||||||
_from_block_dict = {
|
_from_block_dict = {
|
||||||
@@ -254,43 +263,81 @@ class bf_utils:
|
|||||||
|
|
||||||
class ExpandID:
|
class ExpandID:
|
||||||
# fake module
|
# fake module
|
||||||
|
#
|
||||||
|
# TODO:
|
||||||
|
#
|
||||||
|
# Array lookups here are _WAY_ too complicated,
|
||||||
|
# we need some nicer way to represent pointer indirection (easy like in C!)
|
||||||
|
# but for now, use what we have.
|
||||||
|
#
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
raise RuntimeError("%s should not be instantiated" % cls)
|
raise RuntimeError("%s should not be instantiated" % cls)
|
||||||
|
|
||||||
def expand_OB(block):
|
@staticmethod
|
||||||
yield block.get_pointer(b'data')
|
def _expand_generic_material(block):
|
||||||
def expand_ME(block):
|
|
||||||
# TODO, generalize into an ID array
|
|
||||||
array_len = block.get(b'totcol')
|
array_len = block.get(b'totcol')
|
||||||
if array_len != 0:
|
if array_len != 0:
|
||||||
mat = block.get_pointer(b'mat')
|
array = block.get_pointer(b'mat')
|
||||||
# print(mat)
|
for sub_block in bf_utils.iter_array(array, array_len):
|
||||||
print("MATERIALS", array_len)
|
yield sub_block
|
||||||
for item in bf_utils.iter_array(mat, array_len):
|
|
||||||
print(item)
|
|
||||||
|
|
||||||
return
|
@staticmethod
|
||||||
yield none
|
def _expand_generic_mtex(block):
|
||||||
|
field = block.dna_type.field_from_name(b'mtex')
|
||||||
|
array_len = field.dna_size // block.file.header.pointer_size
|
||||||
|
|
||||||
|
for i in range(array_len):
|
||||||
|
path = ('mtex[%d]' % i).encode('ascii')
|
||||||
|
item = block.get_pointer(path)
|
||||||
|
if item:
|
||||||
|
tex = item.get_pointer(b'tex')
|
||||||
|
yield tex
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_OB(block):
|
||||||
|
yield block.get_pointer(b'data')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_ME(block):
|
||||||
|
yield from ExpandID._expand_generic_material(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_ME(block):
|
||||||
|
yield from ExpandID._expand_generic_material(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_CU(block):
|
||||||
|
yield from ExpandID._expand_generic_material(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_MB(block):
|
||||||
|
yield from ExpandID._expand_generic_material(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def expand_MA(block):
|
def expand_MA(block):
|
||||||
|
yield from ExpandID._expand_generic_mtex(block)
|
||||||
print(block)
|
print(block)
|
||||||
return
|
return
|
||||||
yield none
|
yield none
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def expand_TE(block):
|
def expand_TE(block):
|
||||||
return
|
yield block.get_pointer(b'ima')
|
||||||
yield none
|
|
||||||
|
@staticmethod
|
||||||
def expand_GR(block):
|
def expand_GR(block):
|
||||||
sdna_index_GroupObject = block.file.sdna_index_from_id[b'GroupObject']
|
sdna_index_GroupObject = block.file.sdna_index_from_id[b'GroupObject']
|
||||||
for gobj in bf_utils.iter_ListBase(block.get_pointer(b'gobject.first')):
|
for gobj in bf_utils.iter_ListBase(block.get_pointer(b'gobject.first')):
|
||||||
yield gobj.get_pointer(b'ob', sdna_index_refine=sdna_index_GroupObject)
|
yield gobj.get_pointer(b'ob', sdna_index_refine=sdna_index_GroupObject)
|
||||||
|
|
||||||
expand_funcs = {
|
expand_funcs = {
|
||||||
b'OB': expand_OB,
|
b'OB': expand_OB.__func__,
|
||||||
b'ME': expand_ME,
|
b'ME': expand_ME.__func__,
|
||||||
b'MA': expand_MA,
|
b'MA': expand_MA.__func__,
|
||||||
b'TE': expand_TE,
|
b'TE': expand_TE.__func__,
|
||||||
b'GR': expand_GR,
|
b'GR': expand_GR.__func__,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -302,6 +349,9 @@ class utils:
|
|||||||
# fake module
|
# fake module
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
|
def __new__(cls, *args, **kwargs):
|
||||||
|
raise RuntimeError("%s should not be instantiated" % cls)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def abspath(path, start, library=None):
|
def abspath(path, start, library=None):
|
||||||
import os
|
import os
|
||||||
|
Reference in New Issue
Block a user