diff options
author | Jacques Lucke <mail@jlucke.com> | 2019-03-05 17:24:54 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-03-05 17:24:54 +0300 |
commit | 7a6b46aac56b2a529370129bbedcd20f408c6352 (patch) | |
tree | 284f6c4d6b990d5acfebf3bb72c1df4bfcbd7ade /source/blender/blenkernel/intern/particle.c | |
parent | 302bba1665154edc81addfa18d7b8bc8bff6a18d (diff) |
Fix T62163: Duplicating particle system results in crash
There were two problems:
1. `mesh_get_eval_final` has to be called with the evaluated object.
2. Particle systems have to have unique names within an object.
The depsgraph seems to use the particle system name as identifier.
This issue is actually independent of duplication.
The old code used a small hack to create unique names.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4451
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 5d29c8c5941..3146e3f9fd2 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3062,6 +3062,10 @@ ModifierData *object_add_particle_system(Main *bmain, Scene *scene, Object *ob, if (!ob || ob->type != OB_MESH) return NULL; + if (name == NULL) { + name = DATA_("ParticleSettings"); + } + psys = ob->particlesystem.first; for (; psys; psys = psys->next) psys->flag &= ~PSYS_CURRENT; @@ -3069,20 +3073,12 @@ ModifierData *object_add_particle_system(Main *bmain, Scene *scene, Object *ob, psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); psys->pointcache = BKE_ptcache_add(&psys->ptcaches); BLI_addtail(&ob->particlesystem, psys); + psys_unique_name(ob, psys, name); - psys->part = BKE_particlesettings_add(bmain, DATA_("ParticleSettings")); - - if (BLI_listbase_count_at_most(&ob->particlesystem, 2) > 1) - BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_listbase_count(&ob->particlesystem)); - else - BLI_strncpy(psys->name, DATA_("ParticleSystem"), sizeof(psys->name)); + psys->part = BKE_particlesettings_add(bmain, psys->name); md = modifier_new(eModifierType_ParticleSystem); - - if (name) - BLI_strncpy_utf8(md->name, name, sizeof(md->name)); - else - BLI_snprintf(md->name, sizeof(md->name), DATA_("ParticleSystem %i"), BLI_listbase_count(&ob->particlesystem)); + BLI_strncpy(md->name, psys->name, sizeof(md->name)); modifier_unique_name(&ob->modifiers, md); psmd = (ParticleSystemModifierData *) md; |