Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-03-05 17:24:54 +0300
committerJacques Lucke <mail@jlucke.com>2019-03-05 17:24:54 +0300
commit7a6b46aac56b2a529370129bbedcd20f408c6352 (patch)
tree284f6c4d6b990d5acfebf3bb72c1df4bfcbd7ade /source/blender/editors/physics/particle_object.c
parent302bba1665154edc81addfa18d7b8bc8bff6a18d (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/editors/physics/particle_object.c')
-rw-r--r--source/blender/editors/physics/particle_object.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index e10df28a75e..3b063fd7164 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -51,6 +51,7 @@
#include "BKE_report.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "DEG_depsgraph_build.h"
#include "RNA_access.h"
@@ -1069,7 +1070,8 @@ static bool copy_particle_systems_to_object(const bContext *C,
psys_start = totpsys > 0 ? tmp_psys[0] : NULL;
/* Get the evaluated mesh (psys and their modifiers have not been appended yet) */
- final_mesh = mesh_get_eval_final(depsgraph, scene, ob_to, cdmask);
+ Object *ob_to_eval = DEG_get_evaluated_object(depsgraph, ob_to);
+ final_mesh = mesh_get_eval_final(depsgraph, scene, ob_to_eval, cdmask);
/* now append psys to the object and make modifiers */
for (i = 0, psys_from = PSYS_FROM_FIRST;
@@ -1082,6 +1084,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
/* append to the object */
BLI_addtail(&ob_to->particlesystem, psys);
+ psys_unique_name(ob_to, psys, "");
/* add a particle system modifier for each system */
md = modifier_new(eModifierType_ParticleSystem);
@@ -1089,7 +1092,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
/* push on top of the stack, no use trying to reproduce old stack order */
BLI_addtail(&ob_to->modifiers, md);
- BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i);
+ BLI_strncpy(md->name, psys->name, sizeof(md->name));
modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd);
psmd->psys = psys;