fix: material animation support

This commit is contained in:
Swann 2021-06-21 18:58:16 +02:00
parent ad795caed5
commit 9f381b44c8
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB
2 changed files with 8 additions and 7 deletions

View File

@ -219,7 +219,7 @@ def load_fcurve(fcurve_data, fcurve):
def dump_animation_data(datablock):
animation_data = {}
if has_action(datablock):
animation_data['action'] = datablock.animation_data.action.name
animation_data['action'] = datablock.animation_data.action.uuid
if has_driver(datablock):
animation_data['drivers'] = []
for driver in datablock.animation_data.drivers:
@ -241,8 +241,10 @@ def load_animation_data(animation_data, datablock):
for driver in animation_data['drivers']:
load_driver(datablock, driver)
if 'action' in animation_data:
datablock.animation_data.action = bpy.data.actions[animation_data['action']]
action = animation_data.get('action')
if action:
action = resolve_datablock_from_uuid(action, bpy.data.actions)
datablock.animation_data.action = action
elif datablock.animation_data.action:
datablock.animation_data.action = None

View File

@ -411,8 +411,6 @@ class BlMaterial(ReplicatedDatablock):
@staticmethod
def load(data: dict, datablock: object):
load_animation_data(data.get('animation_data'), datablock)
loader = Loader()
is_grease_pencil = data.get('is_grease_pencil')
@ -428,6 +426,7 @@ class BlMaterial(ReplicatedDatablock):
if datablock.node_tree is None:
datablock.use_nodes = True
load_animation_data(data.get('animation_data'), datablock.node_tree)
load_node_tree(data['node_tree'], datablock.node_tree)
@staticmethod
@ -497,7 +496,7 @@ class BlMaterial(ReplicatedDatablock):
elif datablock.use_nodes:
data['node_tree'] = dump_node_tree(datablock.node_tree)
data['animation_data'] = dump_animation_data(datablock)
data['animation_data'] = dump_animation_data(datablock.node_tree)
return data
@staticmethod
@ -512,7 +511,7 @@ class BlMaterial(ReplicatedDatablock):
if datablock.use_nodes:
deps.extend(get_node_tree_dependencies(datablock.node_tree))
deps.extend(resolve_animation_dependencies(datablock))
deps.extend(resolve_animation_dependencies(datablock.node_tree))
return deps