From 914427afd5129954781cf4459067efeb6afa7d14 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 15 Jul 2019 15:27:22 +0200 Subject: Fix T66686: Crash on Particle Edit, then Render Reviewers: brecht, zeddb Reviewed By: brecht Maniphest Tasks: T66686 Differential Revision: https://developer.blender.org/D5259 --- .../depsgraph/intern/eval/deg_eval_copy_on_write.cc | 15 +++++++++++---- source/blender/editors/physics/particle_edit.c | 7 +++++-- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 11fbec62d60..1f310957896 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -685,8 +685,13 @@ void set_particle_system_modifiers_loaded(Object *object_cow) } } -void reset_particle_system_edit_eval(Object *object_cow) +void reset_particle_system_edit_eval(const Depsgraph *depsgraph, Object *object_cow) { + /* Inactive (and render) dependency graphs are living in own little bubble, should not care about + * edit mode at all. */ + if (!DEG_is_active(reinterpret_cast(depsgraph))) { + return; + } LISTBASE_FOREACH (ParticleSystem *, psys, &object_cow->particlesystem) { ParticleSystem *orig_psys = psys->orig_psys; if (orig_psys->edit != NULL) { @@ -696,11 +701,13 @@ void reset_particle_system_edit_eval(Object *object_cow) } } -void update_particles_after_copy(const Object *object_orig, Object *object_cow) +void update_particles_after_copy(const Depsgraph *depsgraph, + const Object *object_orig, + Object *object_cow) { update_particle_system_orig_pointers(object_orig, object_cow); set_particle_system_modifiers_loaded(object_cow); - reset_particle_system_edit_eval(object_cow); + reset_particle_system_edit_eval(depsgraph, object_cow); } void update_pose_orig_pointers(const bPose *pose_orig, bPose *pose_cow) @@ -779,7 +786,7 @@ void update_id_after_copy(const Depsgraph *depsgraph, } BKE_pose_pchan_index_rebuild(object_cow->pose); } - update_particles_after_copy(object_orig, object_cow); + update_particles_after_copy(depsgraph, object_orig, object_cow); update_modifiers_orig_pointers(object_orig, object_cow); break; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 4a55cb6c5c6..4e6022cf18c 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -337,10 +337,13 @@ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *o } } - if (edit) { + /* Don't consider inactive or render dependency graphs, since they might be evaluated for a + * different number of childrem. or have different pointer to evaluated particle system or + * modifier which will also cause troubles. */ + if (edit && DEG_is_active(depsgraph)) { edit->pid = *pid; if (edit->flags & PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL) { - if (edit->psys != NULL) { + if (edit->psys != NULL && edit->psys_eval != NULL) { psys_copy_particles(edit->psys, edit->psys_eval); pe_update_hair_particle_edit_pointers(edit); } -- cgit v1.2.3