Merge pull request #354 from simonebarbieri/bugfix/blender_local_objects_duplicates

bugfix/Blender local objects duplicated
This commit is contained in:
Milan Kolar 2020-07-17 17:37:58 +02:00 committed by GitHub
commit 56c283558d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 44 deletions

View file

@ -79,21 +79,21 @@ class BlendLayoutLoader(plugin.AssetLoader):
# The armature is unparented for all the non-local meshes,
# when it is made local.
for obj in objects + armatures:
obj.make_local()
local_obj = obj.make_local()
if obj.data:
obj.data.make_local()
if not obj.get(blender.pipeline.AVALON_PROPERTY):
obj[blender.pipeline.AVALON_PROPERTY] = dict()
if not local_obj.get(blender.pipeline.AVALON_PROPERTY):
local_obj[blender.pipeline.AVALON_PROPERTY] = dict()
avalon_info = obj[blender.pipeline.AVALON_PROPERTY]
avalon_info = local_obj[blender.pipeline.AVALON_PROPERTY]
avalon_info.update({"container_name": container_name})
action = actions.get(obj.name, None)
action = actions.get(local_obj.name, None)
if local_obj.type == 'ARMATURE' and action is not None:
local_obj.animation_data.action = action
if obj.type == 'ARMATURE' and action is not None:
obj.animation_data.action = action
layout_container.pop(blender.pipeline.AVALON_PROPERTY)
bpy.ops.object.select_all(action='DESELECT')
@ -222,7 +222,8 @@ class BlendLayoutLoader(plugin.AssetLoader):
for obj in objects:
if obj.type == 'ARMATURE':
actions[obj.name] = obj.animation_data.action
if obj.animation_data and obj.animation_data.action:
actions[obj.name] = obj.animation_data.action
self._remove(objects, obj_container)