Fix T52134: New depsgraph crashes when evaluating several psys on from object
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 21 Jul 2017 09:12:34 +0000 (11:12 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 21 Jul 2017 09:12:34 +0000 (11:12 +0200)
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/particle_system.c
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/depsgraph_type_defines.cc
source/blender/depsgraph/intern/depsgraph_types.h

index f9948ba500a90ed32bf7095441dfc9cf20f214da..470e2e468f0219025d52bf27d395c469fe1b8a4e 100644 (file)
@@ -473,9 +473,8 @@ typedef struct ParticleRenderData {
 
 struct EvaluationContext;
 
-void BKE_particle_system_eval(struct EvaluationContext *eval_ctx,
-                              struct Scene *scene,
-                              struct Object *ob,
-                              struct ParticleSystem *psys);
+void BKE_particle_system_eval_init(struct EvaluationContext *eval_ctx,
+                                   struct Scene *scene,
+                                   struct Object *ob);
 
 #endif
index 3f9a92a5577aa3298bcaa6766895cd3be760b3fb..b61f6792c890537a157d137ea144a3559e9883b7 100644 (file)
@@ -4350,13 +4350,12 @@ void BKE_particlesystem_id_loop(ParticleSystem *psys, ParticleSystemIDFunc func,
 
 /* **** Depsgraph evaluation **** */
 
-void BKE_particle_system_eval(EvaluationContext *UNUSED(eval_ctx),
-                              Scene *scene,
-                              Object *ob,
-                              ParticleSystem *psys)
+void BKE_particle_system_eval_init(EvaluationContext *UNUSED(eval_ctx),
+                                   Scene *scene,
+                                   Object *ob)
 {
        if (G.debug & G_DEBUG_DEPSGRAPH) {
-               printf("%s on %s:%s\n", __func__, ob->id.name, psys->name);
+               printf("%s on %s\n", __func__, ob->id.name);
        }
        BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH);
 }
index 55f1f93be6a4d8a7a389eccd2efb7b4dfb615dad..a90f8ff02b63c0fd238d92903563612c003b6228 100644 (file)
@@ -671,6 +671,13 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
        ComponentDepsNode *psys_comp =
                add_component_node(&ob->id, DEG_NODE_TYPE_EVAL_PARTICLES);
 
+       add_operation_node(psys_comp,
+                          function_bind(BKE_particle_system_eval_init,
+                                        _1,
+                                        scene,
+                                        ob),
+                          DEG_OPCODE_PSYS_EVAL_INIT);
+
        /* particle systems */
        LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
                ParticleSettings *part = psys->part;
@@ -682,11 +689,7 @@ void DepsgraphNodeBuilder::build_particles(Scene *scene, Object *ob)
                /* this particle system */
                // TODO: for now, this will just be a placeholder "ubereval" node
                add_operation_node(psys_comp,
-                                  function_bind(BKE_particle_system_eval,
-                                                _1,
-                                                scene,
-                                                ob,
-                                                psys),
+                                  NULL,
                                   DEG_OPCODE_PSYS_EVAL,
                                   psys->name);
        }
index 62a7d6c6ab78d7c6b92214bc59b9981f2685471c..a1abcb9641139af42025371883e036874dd276ee 100644 (file)
@@ -1239,6 +1239,13 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
        OperationKey obdata_ubereval_key(&ob->id,
                                         DEG_NODE_TYPE_GEOMETRY,
                                         DEG_OPCODE_GEOMETRY_UBEREVAL);
+       OperationKey eval_init_key(&ob->id,
+                                  DEG_NODE_TYPE_EVAL_PARTICLES,
+                                  DEG_OPCODE_PSYS_EVAL_INIT);
+       /* TODO(sergey): Are all particle systems depends on time?
+        * Hair without dynamics i.e.
+        */
+       add_relation(time_src_key, eval_init_key, "TimeSrc -> PSys");
 
        /* particle systems */
        LINKLIST_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
@@ -1254,10 +1261,7 @@ void DepsgraphRelationBuilder::build_particles(Scene *scene, Object *ob)
                if (!psys_check_enabled(ob, psys, G.is_rendering))
                        continue;
 
-               /* TODO(sergey): Are all particle systems depends on time?
-                * Hair without dynamics i.e.
-                */
-               add_relation(time_src_key, psys_key, "TimeSrc -> PSys");
+               add_relation(eval_init_key, psys_key, "Init -> PSys");
 
                /* TODO(sergey): Currently particle update is just a placeholder,
                 * hook it to the ubereval node so particle system is getting updated
index 77454cd85ec3b455cc757a733c794969810b2c4b..e5033affe2f6c11b345c462e2db34d0d7f7f226f 100644 (file)
@@ -119,6 +119,7 @@ static const char *stringify_opcode(eDepsOperation_Code opcode)
                STRINGIFY_OPCODE(BONE_READY);
                STRINGIFY_OPCODE(BONE_DONE);
                STRINGIFY_OPCODE(PSYS_EVAL);
+               STRINGIFY_OPCODE(PSYS_EVAL_INIT);
 
                case DEG_NUM_OPCODES: return "SpecialCase";
 #undef STRINGIFY_OPCODE
index c1a42941a7d695d0874980886f44b4bf63cb10f9..f05f82caa3d45bd610aa437c0e455c216071db00 100644 (file)
@@ -219,6 +219,7 @@ typedef enum eDepsOperation_Code {
        /* Particles --------------------------------------- */
 
        /* XXX: placeholder - Particle System eval */
+       DEG_OPCODE_PSYS_EVAL_INIT,
        DEG_OPCODE_PSYS_EVAL,
 
        DEG_NUM_OPCODES,