fix: bl_object

This commit is contained in:
Swann 2021-04-20 09:53:59 +02:00
parent 9312d6a8c5
commit 845bb11b8e
No known key found for this signature in database
GPG Key ID: E1D3641A7C43AACB
2 changed files with 41 additions and 43 deletions

View File

@ -28,21 +28,21 @@ __all__ = [
# 'bl_light',
'bl_scene',
'bl_material',
'bl_library',
'bl_armature',
'bl_action',
'bl_world',
'bl_metaball',
'bl_lattice',
'bl_lightprobe',
'bl_speaker',
'bl_font',
'bl_sound',
'bl_file',
# 'bl_library',
# 'bl_armature',
# 'bl_action',
# 'bl_world',
# 'bl_metaball',
# 'bl_lattice',
# 'bl_lightprobe',
# 'bl_speaker',
# 'bl_font',
# 'bl_sound',
# 'bl_file',
# 'bl_sequencer',
'bl_node_group',
'bl_texture',
"bl_particle",
# 'bl_node_group',
# 'bl_texture',
# "bl_particle",
] # Order here defines execution order
# if bpy.app.version[1] >= 91:

View File

@ -30,7 +30,7 @@ from .bl_action import (load_animation_data,
resolve_animation_dependencies)
from ..preferences import get_preferences
from .bl_datablock import BlDatablock, get_datablock_from_uuid
from .bl_datablock import get_datablock_from_uuid
from .bl_material import IGNORED_SOCKETS
from .dump_anything import (
Dumper,
@ -324,7 +324,7 @@ class BlObject(ReplicatedDatablock):
@staticmethod
def load(data: dict, datablock: bpy.types.Object):
data = node.data
data = datablock.data
load_animation_data(data, datablock)
loader = Loader()
@ -423,20 +423,20 @@ class BlObject(ReplicatedDatablock):
skin_data.data,
SKIN_DATA)
if hasattr(target, 'cycles_visibility') \
if hasattr(datablock, 'cycles_visibility') \
and 'cycles_visibility' in data:
loader.load(target.cycles_visibility, data['cycles_visibility'])
loader.load(datablock.cycles_visibility, data['cycles_visibility'])
# TODO: handle geometry nodes input from dump_anything
if hasattr(target, 'modifiers'):
if hasattr(datablock, 'modifiers'):
nodes_modifiers = [
mod for mod in target.modifiers if mod.type == 'NODES']
mod for mod in datablock.modifiers if mod.type == 'NODES']
for modifier in nodes_modifiers:
load_modifier_geometry_node_inputs(
data['modifiers'][modifier.name], modifier)
particles_modifiers = [
mod for mod in target.modifiers if mod.type == 'PARTICLE_SYSTEM']
mod for mod in datablock.modifiers if mod.type == 'PARTICLE_SYSTEM']
for mod in particles_modifiers:
default = mod.particle_system.settings
@ -451,28 +451,29 @@ class BlObject(ReplicatedDatablock):
bpy.data.particles.remove(default)
phys_modifiers = [
mod for mod in target.modifiers if mod.type in ['SOFT_BODY', 'CLOTH']]
mod for mod in datablock.modifiers if mod.type in ['SOFT_BODY', 'CLOTH']]
for mod in phys_modifiers:
loader.load(mod.settings, data['modifiers'][mod.name]['settings'])
# PHYSICS
load_physics(data, target)
load_physics(data, datablock)
transform = data.get('transforms', None)
if transform:
target.matrix_parent_inverse = mathutils.Matrix(
datablock.matrix_parent_inverse = mathutils.Matrix(
transform['matrix_parent_inverse'])
target.matrix_basis = mathutils.Matrix(transform['matrix_basis'])
target.matrix_local = mathutils.Matrix(transform['matrix_local'])
datablock.matrix_basis = mathutils.Matrix(transform['matrix_basis'])
datablock.matrix_local = mathutils.Matrix(transform['matrix_local'])
def _dump_implementation(self, data, instance=None):
assert(instance)
@staticmethod
def dump(datablock: object) -> dict:
assert(datablock)
if _is_editmode(instance):
if _is_editmode(datablock):
if self.preferences.sync_flags.sync_during_editmode:
instance.update_from_editmode()
datablock.update_from_editmode()
else:
raise ContextError("Object is in edit-mode.")
@ -527,8 +528,8 @@ class BlObject(ReplicatedDatablock):
data['data_uuid'] = getattr(datablock.data, 'uuid', None)
# PARENTING
if instance.parent:
data['parent_uid'] = (instance.parent.uuid, instance.parent.name)
if datablock.parent:
data['parent_uid'] = (datablock.parent.uuid, datablock.parent.name)
# MODIFIERS
if hasattr(datablock, 'modifiers'):
@ -560,7 +561,7 @@ class BlObject(ReplicatedDatablock):
data["modifiers"][modifier.name] = dumped_modifier
gp_modifiers = getattr(instance, 'grease_pencil_modifiers', None)
gp_modifiers = getattr(datablock, 'grease_pencil_modifiers', None)
if gp_modifiers:
dumper.include_filter = None
@ -693,23 +694,20 @@ class BlObject(ReplicatedDatablock):
deps.append(datablock.data)
# Particle systems
for particle_slot in self.instance.particle_systems:
for particle_slot in datablock.particle_systems:
deps.append(particle_slot.settings)
if self.is_library:
deps.append(self.instance.library)
if datablock.parent:
deps.append(datablock.parent)
if self.instance.parent:
deps.append(self.instance.parent)
if self.instance.instance_type == 'COLLECTION':
if datablock.instance_type == 'COLLECTION':
# TODO: uuid based
deps.append(datablock.instance_collection)
deps.extend(resolve_animation_dependencies(datablock))
if self.instance.modifiers:
deps.extend(find_textures_dependencies(self.instance.modifiers))
deps.extend(find_geometry_nodes_dependencies(self.instance.modifiers))
if datablock.modifiers:
deps.extend(find_textures_dependencies(datablock.modifiers))
deps.extend(find_geometry_nodes_dependencies(datablock.modifiers))
return deps