fix: particle system duplication

feat: update Readme
This commit is contained in:
Swann
2021-04-14 15:29:02 +02:00
parent eb631e2d4b
commit 8e606068f3
4 changed files with 58 additions and 41 deletions

View File

@ -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. Currently, not all data-block are supported for replication over the wire. The following list summarizes the status for each ones.
| Name | Status | Comment | | Name | Status | Comment |
| -------------- | :----: | :--------------------------------------------------------------------------: | | -------------- | :----: | :----------------------------------------------------------: |
| action | ✔️ | | | action | ✔️ | |
| armature | | Not stable | | armature | | Not stable |
| camera | ✔️ | | | camera | ✔️ | |
| collection | ✔️ | | | collection | ✔️ | |
| curve | ❗ | Nurbs surfaces not supported | | curve | ❗ | Nurbs surfaces not supported |
| gpencil | ✔️ | [Airbrush not supported](https://gitlab.com/slumber/multi-user/-/issues/123) | | gpencil | ✔️ | |
| image | ✔️ | | | image | ✔️ | |
| mesh | ✔️ | | | mesh | ✔️ | |
| material | ✔️ | | | material | ✔️ | |
| node_groups | ❗ | Material only | | node_groups | ❗ | Material & Geometry only |
| geometry nodes | ✔️ | | | geometry nodes | ✔️ | |
| metaball | ✔️ | | | metaball | ✔️ | |
| object | ✔️ | | | object | ✔️ | |
| textures | ❗ | Supported for modifiers/materials only | | textures | ❗ | Supported for modifiers/materials/geo nodes only |
| texts | ✔️ | | | texts | ✔️ | |
| scene | ✔️ | | | scene | ✔️ | |
| world | ✔️ | | | world | ✔️ | |
| lightprobes | ✔️ | | | lightprobes | ✔️ | |
| compositing | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/46) | | compositing | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/46) |
| texts | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/81) | | texts | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/81) |
| nla | | | | nla | | |
| volumes | ✔️ | | | volumes | ✔️ | |
| particles | | [On-going](https://gitlab.com/slumber/multi-user/-/issues/24) | | particles | | The cache isn't syncing. |
| speakers | ❗ | [Partial](https://gitlab.com/slumber/multi-user/-/issues/65) | | speakers | ❗ | [Partial](https://gitlab.com/slumber/multi-user/-/issues/65) |
| vse | ❗ | Mask and Clip not supported yet | | vse | ❗ | Mask and Clip not supported yet |
| physics | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/45) | | physics | ❌ | [Planned](https://gitlab.com/slumber/multi-user/-/issues/45) |
| libraries | ❗ | Partial | | libraries | ❗ | Partial |
@ -70,7 +70,7 @@ I'm working on it.
| Dependencies | Version | Needed | | Dependencies | Version | Needed |
| ------------ | :-----: | -----: | | ------------ | :-----: | -----: |
| Replication | latest | yes | | Replication | latest | yes |

View File

@ -439,12 +439,24 @@ class BlObject(BlDatablock):
mod for mod in target.modifiers if mod.type == 'PARTICLE_SYSTEM'] mod for mod in target.modifiers if mod.type == 'PARTICLE_SYSTEM']
for mod in particles_modifiers: for mod in particles_modifiers:
loader.load(mod.particle_system, data['modifiers'][mod.name]['particle_system']) default = mod.particle_system.settings.name
# default_settings = mod.particle_system.settings dumped_particles = data['modifiers'][mod.name]['particle_system']
# mod.particle_system.settings = get_datablock_from_uuid(data['modifiers'][mod.name]['particle_system']['settings'], None) loader.load(mod.particle_system, dumped_particles)
# Hack to remove the default generated particle settings settings = get_datablock_from_uuid(dumped_particles['settings_uuid'], None)
# bpy.data.particles.remove(default_settings) 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 # PHYSICS
load_physics(data, target) load_physics(data, target)
@ -457,7 +469,6 @@ class BlObject(BlDatablock):
target.matrix_local = mathutils.Matrix(transform['matrix_local']) target.matrix_local = mathutils.Matrix(transform['matrix_local'])
def _dump_implementation(self, data, instance=None): def _dump_implementation(self, data, instance=None):
assert(instance) assert(instance)
@ -537,13 +548,17 @@ class BlObject(BlDatablock):
modifier) modifier)
dumped_modifier['inputs'] = dumped_inputs dumped_modifier['inputs'] = dumped_inputs
if modifier.type == 'PARTICLE_SYSTEM': elif modifier.type == 'PARTICLE_SYSTEM':
dumper.exclude_filter = [ dumper.exclude_filter = [
"is_edited", "is_edited",
"is_editable", "is_editable",
"is_global_hair" "is_global_hair"
] ]
dumped_modifier['particle_system'] = dumper.dump(modifier.particle_system) 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 data["modifiers"][modifier.name] = dumped_modifier
@ -679,7 +694,7 @@ class BlObject(BlDatablock):
# Particle systems # Particle systems
for particle_slot in self.instance.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: if self.is_library:
deps.append(self.instance.library) deps.append(self.instance.library)

View File

@ -45,7 +45,9 @@ class BlParticle(BlDatablock):
bl_reload_parent = False bl_reload_parent = False
def _construct(self, data): 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): def _load_implementation(self, data, target):
dump_anything.load(target, data) dump_anything.load(target, data)

View File

@ -610,8 +610,8 @@ class Loader:
instance.write(bpy.data.fonts.get(dump)) instance.write(bpy.data.fonts.get(dump))
elif isinstance(rna_property_type, T.Sound): elif isinstance(rna_property_type, T.Sound):
instance.write(bpy.data.sounds.get(dump)) instance.write(bpy.data.sounds.get(dump))
elif isinstance(rna_property_type, T.ParticleSettings): # elif isinstance(rna_property_type, T.ParticleSettings):
instance.write(bpy.data.particles.get(dump)) # instance.write(bpy.data.particles.get(dump))
def _load_matrix(self, matrix, dump): def _load_matrix(self, matrix, dump):
matrix.write(mathutils.Matrix(dump)) matrix.write(mathutils.Matrix(dump))