Expand more data-types
This commit is contained in:
130
packer/packer.py
130
packer/packer.py
@@ -223,6 +223,7 @@ class FilePath:
|
|||||||
if fn is not None:
|
if fn is not None:
|
||||||
yield from fn(block, basedir, rootdir, level)
|
yield from fn(block, basedir, rootdir, level)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def _from_block_IM(block, basedir, rootdir, level):
|
def _from_block_IM(block, basedir, rootdir, level):
|
||||||
# (IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)
|
# (IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)
|
||||||
if block[b'source'] not in {1, 2, 3}:
|
if block[b'source'] not in {1, 2, 3}:
|
||||||
@@ -232,19 +233,21 @@ class FilePath:
|
|||||||
|
|
||||||
yield FilePath(block, b'name', basedir, level), rootdir
|
yield FilePath(block, b'name', basedir, level), rootdir
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def _from_block_LI(block, basedir, rootdir, level):
|
def _from_block_LI(block, basedir, rootdir, level):
|
||||||
if block[b'packedfile']:
|
if block[b'packedfile']:
|
||||||
return
|
return
|
||||||
|
|
||||||
yield FilePath(block, b'name', basedir, level), rootdir
|
yield FilePath(block, b'name', basedir, level), rootdir
|
||||||
|
|
||||||
|
# _from_block_IM --> {b'IM': _from_block_IM, ...}
|
||||||
_from_block_dict = {
|
_from_block_dict = {
|
||||||
b'IM': _from_block_IM,
|
k.rpartition("_")[2].encode('ascii'): s_fn.__func__ for k, s_fn in locals().items()
|
||||||
b'LI': _from_block_LI,
|
if isinstance(s_fn, staticmethod)
|
||||||
|
if k.startswith("_from_block_")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class bf_utils:
|
class bf_utils:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def iter_ListBase(block):
|
def iter_ListBase(block):
|
||||||
@@ -300,8 +303,8 @@ class ExpandID:
|
|||||||
path = ('mtex[%d]' % i).encode('ascii')
|
path = ('mtex[%d]' % i).encode('ascii')
|
||||||
item = block.get_pointer(path)
|
item = block.get_pointer(path)
|
||||||
if item:
|
if item:
|
||||||
tex = item.get_pointer(b'tex')
|
yield item.get_pointer(b'tex')
|
||||||
yield tex
|
yield item.get_pointer(b'object')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _expand_generic_nodetree(block):
|
def _expand_generic_nodetree(block):
|
||||||
@@ -311,57 +314,102 @@ class ExpandID:
|
|||||||
for item in bf_utils.iter_ListBase(block.get_pointer(b'nodes.first')):
|
for item in bf_utils.iter_ListBase(block.get_pointer(b'nodes.first')):
|
||||||
item_type = item.get(b'type', sdna_index_refine=sdna_index_bNode)
|
item_type = item.get(b'type', sdna_index_refine=sdna_index_bNode)
|
||||||
|
|
||||||
if item_type == 143: # SH_NODE_TEX_IMAGE
|
if item_type != 221: # CMP_NODE_R_LAYERS
|
||||||
yield item.get_pointer(b'id', sdna_index_refine=sdna_index_bNode)
|
yield item.get_pointer(b'id', sdna_index_refine=sdna_index_bNode)
|
||||||
|
|
||||||
# import IPython; IPython.embed()
|
# import IPython; IPython.embed()
|
||||||
# print(item.get(b'name', sdna_index_refine=sdna_index_bNode))
|
# print(item.get(b'name', sdna_index_refine=sdna_index_bNode))
|
||||||
# print(item.get(b'type', sdna_index_refine=sdna_index_bNode))
|
# print(item.get(b'type', sdna_index_refine=sdna_index_bNode))
|
||||||
|
#
|
||||||
@staticmethod
|
def _expand_generic_nodetree_id(block):
|
||||||
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):
|
|
||||||
yield from ExpandID._expand_generic_mtex(block)
|
|
||||||
|
|
||||||
block_ntree = block.get_pointer(b'nodetree')
|
block_ntree = block.get_pointer(b'nodetree')
|
||||||
if block_ntree is not None:
|
if block_ntree is not None:
|
||||||
yield from ExpandID._expand_generic_nodetree(block_ntree)
|
yield from ExpandID._expand_generic_nodetree(block_ntree)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def expand_TE(block):
|
def _expand_generic_animdata(block):
|
||||||
|
block_adt = block.get_pointer(b'adt')
|
||||||
|
if block_adt:
|
||||||
|
yield block_adt.get_pointer(b'action')
|
||||||
|
# TODO, NLA
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_OB(block): # 'Object'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield block.get_pointer(b'data')
|
||||||
|
yield block.get_pointer(b'dup_group')
|
||||||
|
|
||||||
|
yield block.get_pointer(b'proxy')
|
||||||
|
yield block.get_pointer(b'proxy_group')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_ME(block): # 'Mesh'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_material(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_CU(block): # 'Curve'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_material(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_MB(block): # 'MBall'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_material(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_LA(block): # 'Lamp'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_nodetree_id(block)
|
||||||
|
yield from ExpandID._expand_generic_mtex(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_MA(block): # 'Material'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_nodetree_id(block)
|
||||||
|
yield from ExpandID._expand_generic_mtex(block)
|
||||||
|
|
||||||
|
yield block.get_pointer(b'group')
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_TE(block): # 'Tex'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_nodetree_id(block)
|
||||||
yield block.get_pointer(b'ima')
|
yield block.get_pointer(b'ima')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def expand_GR(block):
|
def expand_WO(block): # 'World'
|
||||||
sdna_index_GroupObject = block.file.sdna_index_from_id[b'GroupObject']
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
for gobj in bf_utils.iter_ListBase(block.get_pointer(b'gobject.first')):
|
yield from ExpandID._expand_generic_nodetree_id(block)
|
||||||
yield gobj.get_pointer(b'ob', sdna_index_refine=sdna_index_GroupObject)
|
yield from ExpandID._expand_generic_mtex(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_NT(block): # 'bNodeTree'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_nodetree(block)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_SC(block): # 'Scene'
|
||||||
|
yield from ExpandID._expand_generic_animdata(block)
|
||||||
|
yield from ExpandID._expand_generic_nodetree_id(block)
|
||||||
|
yield block.get_pointer(b'world')
|
||||||
|
|
||||||
|
sdna_index_Base = block.file.sdna_index_from_id[b'Base']
|
||||||
|
for item in bf_utils.iter_ListBase(block.get_pointer(b'base.first')):
|
||||||
|
yield item.get_pointer(b'object', sdna_index_refine=sdna_index_Base)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def expand_GR(block): # 'Group'
|
||||||
|
sdna_index_GroupObject = block.file.sdna_index_from_id[b'GroupObject']
|
||||||
|
for item in bf_utils.iter_ListBase(block.get_pointer(b'gobject.first')):
|
||||||
|
yield item.get_pointer(b'ob', sdna_index_refine=sdna_index_GroupObject)
|
||||||
|
|
||||||
|
# expand_GR --> {b'GR': expand_GR, ...}
|
||||||
expand_funcs = {
|
expand_funcs = {
|
||||||
b'OB': expand_OB.__func__,
|
k.rpartition("_")[2].encode('ascii'): s_fn.__func__ for k, s_fn in locals().items()
|
||||||
b'ME': expand_ME.__func__,
|
if isinstance(s_fn, staticmethod)
|
||||||
b'MA': expand_MA.__func__,
|
if k.startswith("expand_")
|
||||||
b'TE': expand_TE.__func__,
|
|
||||||
b'GR': expand_GR.__func__,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user