fix: prevent matrix_parent_inverse from being reset by loading parents only if its necessary

This commit is contained in:
Swann 2021-03-03 11:00:47 +01:00
parent 19c56e590b
commit cc5a87adb8
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB

View File

@ -300,8 +300,14 @@ class BlObject(BlDatablock):
if 'display' in data:
loader.load(target.display, data['display'])
# Parent
if 'parent' not in data and target.parent:
# Parenting
parent_id = data.get('parent_id')
if parent_id:
parent = bpy.data.objects[parent_id]
# Avoid reloading
if target.parent != parent and parent is not None:
target.parent = parent
elif target.parent:
target.parent = None
# Pose
@ -371,10 +377,6 @@ class BlObject(BlDatablock):
dumper.include_filter = [
"name",
"rotation_mode",
"parent",
"parent_type",
"track_axis",
"up_axis",
"data",
"library",
"empty_display_type",
@ -419,6 +421,10 @@ class BlObject(BlDatablock):
if self.is_library:
return data
# PARENTING
if instance.parent:
data['parent_id'] = instance.parent.name
# MODIFIERS
if hasattr(instance, 'modifiers'):
data["modifiers"] = {}
@ -561,6 +567,9 @@ class BlObject(BlDatablock):
if self.is_library:
deps.append(self.instance.library)
if self.instance.parent :
deps.append(self.instance.parent)
if self.instance.instance_type == 'COLLECTION':
# TODO: uuid based
deps.append(self.instance.instance_collection)