From 8e606068f3e201acb711a1c3c806608d8a58eb97 Mon Sep 17 00:00:00 2001 From: Swann Date: Wed, 14 Apr 2021 15:29:02 +0200 Subject: [PATCH] fix: particle system duplication feat: update Readme --- README.md | 60 ++++++++++++++-------------- multi_user/bl_types/bl_object.py | 31 ++++++++++---- multi_user/bl_types/bl_particle.py | 4 +- multi_user/bl_types/dump_anything.py | 4 +- 4 files changed, 58 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index d2c8991..051ef32 100644 --- a/README.md +++ b/README.md @@ -29,35 +29,35 @@ See the [troubleshooting guide](https://slumber.gitlab.io/multi-user/getting_sta Currently, not all data-block are supported for replication over the wire. The following list summarizes the status for each ones. -| Name | Status | Comment | -| -------------- | :----: | :--------------------------------------------------------------------------: | -| action | ✔️ | | -| armature | ❗ | Not stable | -| camera | ✔️ | | -| collection | ✔️ | | -| curve | ❗ | Nurbs surfaces not supported | -| gpencil | ✔️ | [Airbrush not supported](https://gitlab.com/slumber/multi-user/-/issues/123) | -| image | ✔️ | | -| mesh | ✔️ | | -| material | ✔️ | | -| node_groups | ❗ | Material only | -| geometry nodes | ✔️ | | -| metaball | ✔️ | | -| object | ✔️ | | -| textures | ❗ | Supported for modifiers/materials only | -| texts | ✔️ | | -| scene | ✔️ | | -| world | ✔️ | | -| lightprobes | ✔️ | | -| compositing | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/46) | -| texts | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/81) | -| nla | ❌ | | -| volumes | ✔️ | | -| particles | ❌ | [On-going](https://gitlab.com/slumber/multi-user/-/issues/24) | -| speakers | ❗ | [Partial](https://gitlab.com/slumber/multi-user/-/issues/65) | -| vse | ❗ | Mask and Clip not supported yet | -| physics | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/45) | -| libraries | ❗ | Partial | +| Name | Status | Comment | +| -------------- | :----: | :----------------------------------------------------------: | +| action | ✔️ | | +| armature | ❗ | Not stable | +| camera | ✔️ | | +| collection | ✔️ | | +| curve | ❗ | Nurbs surfaces not supported | +| gpencil | ✔️ | | +| image | ✔️ | | +| mesh | ✔️ | | +| material | ✔️ | | +| node_groups | ❗ | Material & Geometry only | +| geometry nodes | ✔️ | | +| metaball | ✔️ | | +| object | ✔️ | | +| textures | ❗ | Supported for modifiers/materials/geo nodes only | +| texts | ✔️ | | +| scene | ✔️ | | +| world | ✔️ | | +| lightprobes | ✔️ | | +| compositing | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/46) | +| texts | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/81) | +| nla | ❌ | | +| volumes | ✔️ | | +| particles | ❗ | The cache isn't syncing. | +| speakers | ❗ | [Partial](https://gitlab.com/slumber/multi-user/-/issues/65) | +| vse | ❗ | Mask and Clip not supported yet | +| physics | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/45) | +| libraries | ❗ | Partial | @@ -70,7 +70,7 @@ I'm working on it. | Dependencies | Version | Needed | | ------------ | :-----: | -----: | -| Replication | latest | yes | +| Replication | latest | yes | diff --git a/multi_user/bl_types/bl_object.py b/multi_user/bl_types/bl_object.py index e625cac..fd9bbd5 100644 --- a/multi_user/bl_types/bl_object.py +++ b/multi_user/bl_types/bl_object.py @@ -439,12 +439,24 @@ class BlObject(BlDatablock): mod for mod in target.modifiers if mod.type == 'PARTICLE_SYSTEM'] for mod in particles_modifiers: - loader.load(mod.particle_system, data['modifiers'][mod.name]['particle_system']) - # default_settings = mod.particle_system.settings - # mod.particle_system.settings = get_datablock_from_uuid(data['modifiers'][mod.name]['particle_system']['settings'], None) + default = mod.particle_system.settings.name + dumped_particles = data['modifiers'][mod.name]['particle_system'] + loader.load(mod.particle_system, dumped_particles) - # Hack to remove the default generated particle settings - # bpy.data.particles.remove(default_settings) + settings = get_datablock_from_uuid(dumped_particles['settings_uuid'], None) + if settings: + mod.particle_system.settings = settings + + # Hack to remove the default generated particle settings + for settings in bpy.data.particles: + if settings.users == 0: + bpy.data.particles.remove(settings) + + phys_modifiers = [ + mod for mod in target.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) @@ -456,7 +468,6 @@ class BlObject(BlDatablock): target.matrix_basis = mathutils.Matrix(transform['matrix_basis']) target.matrix_local = mathutils.Matrix(transform['matrix_local']) - def _dump_implementation(self, data, instance=None): assert(instance) @@ -537,13 +548,17 @@ class BlObject(BlDatablock): modifier) dumped_modifier['inputs'] = dumped_inputs - if modifier.type == 'PARTICLE_SYSTEM': + elif modifier.type == 'PARTICLE_SYSTEM': dumper.exclude_filter = [ "is_edited", "is_editable", "is_global_hair" ] dumped_modifier['particle_system'] = dumper.dump(modifier.particle_system) + dumped_modifier['particle_system']['settings_uuid'] = modifier.particle_system.settings.uuid + + elif modifier.type in ['SOFT_BODY', 'CLOTH']: + dumped_modifier['settings'] = dumper.dump(modifier.settings) data["modifiers"][modifier.name] = dumped_modifier @@ -679,7 +694,7 @@ class BlObject(BlDatablock): # Particle systems for particle_slot in self.instance.particle_systems: - deps.append(bpy.data.particles[particle_slot.name]) + deps.append(particle_slot.settings) if self.is_library: deps.append(self.instance.library) diff --git a/multi_user/bl_types/bl_particle.py b/multi_user/bl_types/bl_particle.py index b7d7697..2ec6fac 100644 --- a/multi_user/bl_types/bl_particle.py +++ b/multi_user/bl_types/bl_particle.py @@ -45,7 +45,9 @@ class BlParticle(BlDatablock): bl_reload_parent = False def _construct(self, data): - return bpy.data.particles.new(data["name"]) + instance = bpy.data.particles.new(data["name"]) + instance.uuid = self.uuid + return instance def _load_implementation(self, data, target): dump_anything.load(target, data) diff --git a/multi_user/bl_types/dump_anything.py b/multi_user/bl_types/dump_anything.py index 10e1293..2b97ecb 100644 --- a/multi_user/bl_types/dump_anything.py +++ b/multi_user/bl_types/dump_anything.py @@ -610,8 +610,8 @@ class Loader: instance.write(bpy.data.fonts.get(dump)) elif isinstance(rna_property_type, T.Sound): instance.write(bpy.data.sounds.get(dump)) - elif isinstance(rna_property_type, T.ParticleSettings): - instance.write(bpy.data.particles.get(dump)) + # elif isinstance(rna_property_type, T.ParticleSettings): + # instance.write(bpy.data.particles.get(dump)) def _load_matrix(self, matrix, dump): matrix.write(mathutils.Matrix(dump))