Depsgraph: Make dependency graph to be built from scene layer
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 9 Nov 2017 10:20:17 +0000 (11:20 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 9 Nov 2017 10:20:17 +0000 (11:20 +0100)
This is a final step of having proper ownership. Now selecting different
layers in the "top bar" will actually do what this is expected to do.

Surely, there are still things to be done under the hood, that will happen
in a less intrusive way.

42 files changed:
source/blender/alembic/intern/abc_exporter.cc
source/blender/alembic/intern/abc_exporter.h
source/blender/alembic/intern/alembic_capi.cc
source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/workspace.c
source/blender/depsgraph/CMakeLists.txt
source/blender/depsgraph/DEG_depsgraph_build.h
source/blender/depsgraph/DEG_depsgraph_debug.h
source/blender/depsgraph/intern/builder/deg_builder_nodes.h
source/blender/depsgraph/intern/builder/deg_builder_nodes_scene_layer.cc [moved from source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc with 85% similarity]
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/builder/deg_builder_relations_scene_layer.cc [moved from source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc with 89% similarity]
source/blender/depsgraph/intern/depsgraph.cc
source/blender/depsgraph/intern/depsgraph.h
source/blender/depsgraph/intern/depsgraph_build.cc
source/blender/depsgraph/intern/depsgraph_debug.cc
source/blender/depsgraph/intern/depsgraph_query.cc
source/blender/editors/include/ED_screen.h
source/blender/editors/object/object_add.c
source/blender/editors/physics/dynamicpaint_ops.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/render/render_internal.c
source/blender/editors/render/render_opengl.c
source/blender/editors/render/render_preview.c
source/blender/editors/scene/scene_edit.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sound/sound_ops.c
source/blender/editors/transform/transform_conversions.c
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/makesrna/intern/rna_scene_api.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/external_engine.c
source/blender/render/intern/source/pipeline.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c
source/creator/creator_args.c
tests/gtests/alembic/abc_export_test.cc

index 51e2e7040f9cbfdb801fe635d7f2a54db398b323..af6cf6556526b1e23f73a65a41a57a8e89f015f6 100644 (file)
@@ -168,7 +168,8 @@ static bool export_object(const ExportSettings * const settings, const Base * co
 
 /* ************************************************************************** */
 
-AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Depsgraph *depsgraph,
+AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+                         Depsgraph *depsgraph,
                          const char *filename, ExportSettings &settings)
     : m_bmain(bmain)
     , m_settings(settings)
@@ -177,6 +178,7 @@ AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene,
     , m_shape_sampling_index(0)
     , m_eval_ctx(eval_ctx)
     , m_scene(scene)
+    , m_scene_layer(scene_layer)
     , m_depsgraph(depsgraph)
     , m_writer(NULL)
 {}
@@ -655,5 +657,5 @@ void AbcExporter::setCurrentFrame(Main *bmain, double t)
 {
        m_scene->r.cfra = static_cast<int>(t);
        m_scene->r.subframe = static_cast<float>(t) - m_scene->r.cfra;
-       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, m_depsgraph, bmain, m_scene);
+       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, m_depsgraph, bmain, m_scene, m_scene_layer);
 }
index d0f3964abd59829d67c4fba84669d54c17d00aea..816e2db725bcd3ffba9ad2d8e99334b7e385fcf8 100644 (file)
@@ -95,6 +95,7 @@ class AbcExporter {
 
        EvaluationContext *m_eval_ctx;
        Scene *m_scene;
+       SceneLayer *m_scene_layer;
        Depsgraph *m_depsgraph;
 
        ArchiveWriter *m_writer;
@@ -106,7 +107,8 @@ class AbcExporter {
        std::vector<AbcObjectWriter *> m_shapes;
 
 public:
-       AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Depsgraph *depsgraph,
+       AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, SceneLayer *scene_layer,
+                   Depsgraph *depsgraph,
                    const char *filename, ExportSettings &settings);
        ~AbcExporter();
 
index d17182a0d6569862bc9c1a6194d1d142affdc2a2..e4d6357a1be735d737e1933712b03a6290687368 100644 (file)
@@ -232,6 +232,7 @@ static void find_iobject(const IObject &object, IObject &ret,
 struct ExportJobData {
        EvaluationContext eval_ctx;
        Scene *scene;
+       SceneLayer *scene_layer;
        Depsgraph *depsgraph;
        Main *bmain;
 
@@ -264,7 +265,8 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
 
        try {
                Scene *scene = data->scene;
-               AbcExporter exporter(data->bmain, &data->eval_ctx, scene, data->depsgraph, data->filename, data->settings);
+               SceneLayer *scene_layer = data->scene_layer;
+               AbcExporter exporter(data->bmain, &data->eval_ctx, scene, scene_layer, data->depsgraph, data->filename, data->settings);
 
                const int orig_frame = CFRA;
 
@@ -274,7 +276,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
                if (CFRA != orig_frame) {
                        CFRA = orig_frame;
 
-                       BKE_scene_graph_update_for_newframe(data->bmain->eval_ctx, data->depsgraph, data->bmain, scene);
+                       BKE_scene_graph_update_for_newframe(data->bmain->eval_ctx, data->depsgraph, data->bmain, scene, data->scene_layer);
                }
 
                data->export_ok = !data->was_canceled;
@@ -316,6 +318,7 @@ bool ABC_export(
        CTX_data_eval_ctx(C, &job->eval_ctx);
 
        job->scene = scene;
+       job->scene_layer = CTX_data_scene_layer(C);
        job->depsgraph = CTX_data_depsgraph(C);
        job->bmain = CTX_data_main(C);
        job->export_ok = false;
index 04761b3fa9e953bdfab7ea7b0930c8a02dfc2b3a..fac11edea75f3affdabc6b936fb7ede25f18eb17 100644 (file)
@@ -144,12 +144,14 @@ void  BKE_scene_frame_set(struct Scene *scene, double cfra);
 void BKE_scene_graph_update_tagged(struct EvaluationContext *eval_ctx,
                                    struct Depsgraph *depsgraph,
                                    struct Main *bmain,
-                                   struct Scene *scene);
+                                   struct Scene *scene,
+                                   struct SceneLayer *scene_layer);
 
 void BKE_scene_graph_update_for_newframe(struct EvaluationContext *eval_ctx,
                                          struct Depsgraph *depsgraph,
                                          struct Main *bmain,
-                                         struct Scene *sce);
+                                         struct Scene *scene,
+                                         struct SceneLayer *scene_layer);
 
 struct SceneRenderLayer *BKE_scene_add_render_layer(struct Scene *sce, const char *name);
 bool BKE_scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl);
index 23fbcf583ad7cefd23a9efacb90c37a6b48853f7..eb63ea5250dc9e40e892244a6010c732d201c881 100644 (file)
@@ -276,7 +276,10 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
 /* ........ */
 
 /* update scene for current frame */
-static void motionpaths_calc_update_scene(Main *bmain, Scene *scene, struct Depsgraph *depsgraph)
+static void motionpaths_calc_update_scene(Main *bmain,
+                                          Scene *scene,
+                                          SceneLayer *scene_layer,
+                                          struct Depsgraph *depsgraph)
 {
        /* Do all updates
         *  - if this is too slow, resort to using a more efficient way
@@ -288,7 +291,7 @@ static void motionpaths_calc_update_scene(Main *bmain, Scene *scene, struct Deps
         *
         * TODO(sergey): Use evaluation context dedicated to motion paths.
         */
-       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
 }
 
 /* ........ */
@@ -344,6 +347,8 @@ void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
        int sfra, efra;
        int cfra;
        Main *bmain = CTX_data_main(C);
+       /* TODO(sergey): Should we mabe pass scene layer explicitly? */
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
        struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
        
        /* sanity check */
@@ -367,7 +372,7 @@ void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
        /* calculate path over requested range */
        for (CFRA = sfra; CFRA <= efra; CFRA++) {
                /* update relevant data for new frame */
-               motionpaths_calc_update_scene(bmain, scene, depsgraph);
+               motionpaths_calc_update_scene(bmain, scene, scene_layer, depsgraph);
                
                /* perform baking for targets */
                motionpaths_calc_bake_targets(scene, targets);
@@ -375,7 +380,7 @@ void animviz_calc_motionpaths(bContext *C, Scene *scene, ListBase *targets)
        
        /* reset original environment */
        CFRA = cfra;
-       motionpaths_calc_update_scene(bmain, scene, depsgraph);
+       motionpaths_calc_update_scene(bmain, scene, scene_layer, depsgraph);
        
        /* clear recalc flags from targets */
        for (mpt = targets->first; mpt; mpt = mpt->next) {
index 4d1c2d8454b9f54797fc820946afbe3df90c03b8..abe8c8f8981c286914ebf4ebd1b21281ee184c3f 100644 (file)
@@ -3662,7 +3662,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
        stime = ptime = PIL_check_seconds_timer();
 
        for (int fr = CFRA; fr <= endframe; fr += baker->quick_step, CFRA = fr) {
-               BKE_scene_graph_update_for_newframe(G.main->eval_ctx, depsgraph, bmain, scene);
+               BKE_scene_graph_update_for_newframe(G.main->eval_ctx, depsgraph, bmain, scene, scene_layer);
 
                if (baker->update_progress) {
                        float progress = ((float)(CFRA - startframe)/(float)(endframe - startframe));
@@ -3748,7 +3748,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker)
        CFRA = cfrao;
        
        if (bake) { /* already on cfra unless baking */
-               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
        }
 
        /* TODO: call redraw all windows somehow */
index 95f10cc9846c10722ad4f05335d09a8b179661a5..ccdd785986d75f196279f05e10edc434d435f329 100644 (file)
@@ -1537,13 +1537,19 @@ static void prepare_mesh_for_viewport_render(Main *bmain, Scene *scene)
 void BKE_scene_graph_update_tagged(EvaluationContext *eval_ctx,
                                    Depsgraph *depsgraph,
                                    Main *bmain,
-                                   Scene *scene)
+                                   Scene *scene,
+                                   SceneLayer *scene_layer)
 {
+       /* TODO(sergey): Temporary solution for until pipeline.c is ported. */
+       if (scene_layer == NULL) {
+               scene_layer = DEG_get_evaluated_scene_layer(depsgraph);
+               BLI_assert(scene_layer != NULL);
+       }
        /* TODO(sergey): Some functions here are changing global state,
         * for example, clearing update tags from bmain.
         */
        /* (Re-)build dependency graph if needed. */
-       DEG_graph_relations_update(depsgraph, bmain, scene);
+       DEG_graph_relations_update(depsgraph, bmain, scene, scene_layer);
        /* Uncomment this to check if graph was properly tagged for update. */
        // DEG_debug_graph_relations_validate(depsgraph, bmain, scene);
        /* Flush editing data if needed. */
@@ -1566,8 +1572,14 @@ void BKE_scene_graph_update_tagged(EvaluationContext *eval_ctx,
 void BKE_scene_graph_update_for_newframe(EvaluationContext *eval_ctx,
                                          Depsgraph *depsgraph,
                                          Main *bmain,
-                                         Scene *scene)
+                                         Scene *scene,
+                                         SceneLayer *scene_layer)
 {
+       /* TODO(sergey): Temporary solution for until pipeline.c is ported. */
+       if (scene_layer == NULL) {
+               scene_layer = DEG_get_evaluated_scene_layer(depsgraph);
+               BLI_assert(scene_layer != NULL);
+       }
        /* TODO(sergey): Some functions here are changing global state,
         * for example, clearing update tags from bmain.
         */
@@ -1583,7 +1595,7 @@ void BKE_scene_graph_update_for_newframe(EvaluationContext *eval_ctx,
         */
        BKE_image_update_frame(bmain, scene->r.cfra);
        BKE_sound_set_cfra(scene->r.cfra);
-       DEG_graph_relations_update(depsgraph, bmain, scene);
+       DEG_graph_relations_update(depsgraph, bmain, scene, scene_layer);
        /* Update animated cache files for modifiers.
         *
         * TODO(sergey): Make this a depsgraph node?
index 11c3a5658e82801aa5b55620daf3668fbea4434b..3e1ebc2a05727844b4cd56e3e5c743e7aa11c9c5 100644 (file)
@@ -3315,7 +3315,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
 
                /* opengl offscreen render */
                context->eval_ctx->engine = RE_engines_find(scene->view_render.engine_id);
-               BKE_scene_graph_update_for_newframe(context->eval_ctx, depsgraph, context->bmain, scene);
+               BKE_scene_graph_update_for_newframe(context->eval_ctx, depsgraph, context->bmain, scene, scene_layer);
                ibuf = sequencer_view3d_cb(
                        /* set for OpenGL render (NULL when scrubbing) */
                        context->eval_ctx, scene, scene_layer, camera, width, height, IB_rect,
@@ -3355,7 +3355,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
                        RE_SetDepsgraph(re, depsgraph);
                        DEG_graph_id_tag_update(context->bmain, depsgraph, &scene->id, 0);
 
-                       BKE_scene_graph_update_for_newframe(context->eval_ctx, depsgraph, context->bmain, scene);
+                       BKE_scene_graph_update_for_newframe(context->eval_ctx, depsgraph, context->bmain, scene, scene_layer);
                        RE_BlenderFrame(re, context->bmain, scene, NULL, camera, scene->lay, frame, false);
 
                        /* restore previous state after it was toggled on & off by RE_BlenderFrame */
@@ -3415,7 +3415,7 @@ finally:
        scene->r.subframe = orig_data.subframe;
 
        if (is_frame_update) {
-               BKE_scene_graph_update_for_newframe(context->eval_ctx, depsgraph, context->bmain, scene);
+               BKE_scene_graph_update_for_newframe(context->eval_ctx, depsgraph, context->bmain, scene, scene_layer);
        }
 
 #ifdef DURIAN_CAMERA_SWITCH
index 79e1af810a50f2387d9b34b1b6ac2942e8ab864c..fec9d736e093d93bdec5b26ec191b94c32a55301 100644 (file)
@@ -481,5 +481,5 @@ void BKE_workspace_update_tagged(struct EvaluationContext *eval_ctx,
        struct Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene,
                                                              scene_layer,
                                                              true);
-       BKE_scene_graph_update_tagged(eval_ctx, depsgraph, bmain, scene);
+       BKE_scene_graph_update_tagged(eval_ctx, depsgraph, bmain, scene, scene_layer);
 }
index eae3e402850ec17f7b9b6fb0a790cf47c72cf3fe..64fa5ddfb3d1bc6c35d4aec36779020751f9187e 100644 (file)
@@ -45,13 +45,13 @@ set(SRC
        intern/builder/deg_builder_nodes.cc
        intern/builder/deg_builder_nodes_layer.cc
        intern/builder/deg_builder_nodes_rig.cc
-       intern/builder/deg_builder_nodes_scene.cc
+       intern/builder/deg_builder_nodes_scene_layer.cc
        intern/builder/deg_builder_pchanmap.cc
        intern/builder/deg_builder_relations.cc
        intern/builder/deg_builder_relations_keys.cc
        intern/builder/deg_builder_relations_layer.cc
        intern/builder/deg_builder_relations_rig.cc
-       intern/builder/deg_builder_relations_scene.cc
+       intern/builder/deg_builder_relations_scene_layer.cc
        intern/builder/deg_builder_transitive.cc
        intern/debug/deg_debug_graphviz.cc
        intern/eval/deg_eval.cc
index 06202b6196ec2f6434ecad014a61e2f699e8e910..e328d3d9e8c2750aa5fd31bd83acbde005297411 100644 (file)
@@ -48,6 +48,7 @@ struct Main;
 struct ModifierData;
 struct Object;
 struct Scene;
+struct SceneLayer;
 
 #ifdef __cplusplus
 extern "C" {
@@ -58,9 +59,10 @@ extern "C" {
 /* Build depsgraph for the given scene, and dump results in given
  * graph container.
  */
-void DEG_graph_build_from_scene(struct Depsgraph *graph,
-                                struct Main *bmain,
-                                struct Scene *scene);
+void DEG_graph_build_from_scene_layer(struct Depsgraph *graph,
+                                      struct Main *bmain,
+                                      struct Scene *scene,
+                                      struct SceneLayer *scene_layer);
 
 /* Tag relations from the given graph for update. */
 void DEG_graph_tag_relations_update(struct Depsgraph *graph);
@@ -68,7 +70,8 @@ void DEG_graph_tag_relations_update(struct Depsgraph *graph);
 /* Create or update relations in the specified graph. */
 void DEG_graph_relations_update(struct Depsgraph *graph,
                                 struct Main *bmain,
-                                struct Scene *scene);
+                                struct Scene *scene,
+                                struct SceneLayer *scene_layer);
 
 /* Tag all relations in the database for update.*/
 void DEG_relations_tag_update(struct Main *bmain);
index 7546f1d90188cc43bc9db84c9c4de244f6c6b769..fd6dff4c9731322cb2205f7c666c6f67071b8ec9 100644 (file)
@@ -40,6 +40,8 @@ extern "C" {
 #endif
 
 struct Depsgraph;
+struct Scene;
+struct SceneLayer;
 
 /* ------------------------------------------------ */
 
@@ -62,8 +64,8 @@ bool DEG_debug_compare(const struct Depsgraph *graph1,
 /* Check that dependnecies in the graph are really up to date. */
 bool DEG_debug_graph_relations_validate(struct Depsgraph *graph,
                                         struct Main *bmain,
-                                        struct Scene *scene);
-
+                                        struct Scene *scene,
+                                        struct SceneLayer *scene_layer);
 
 /* Perform consistency check on the graph. */
 bool DEG_debug_consistency_check(struct Depsgraph *graph);
index 40d6a56e789181ae2266ee4f2bcbbf0b100aef4b..4a311cec4bdf9cf0f514f33882850388e2f445d7 100644 (file)
@@ -157,8 +157,9 @@ struct DepsgraphNodeBuilder {
                                               const char *name = "",
                                               int name_tag = -1);
 
-       void build_scene(Scene *scene,
-                        eDepsNode_LinkedState_Type linked_state);
+       void build_scene_layer(Scene *scene,
+                              SceneLayer *scene_layer,
+                              eDepsNode_LinkedState_Type linked_state);
        void build_group(Group *group);
        void build_object(Object *ob,
                          eDepsNode_LinkedState_Type linked_state);
similarity index 85%
rename from source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
rename to source/blender/depsgraph/intern/builder/deg_builder_nodes_scene_layer.cc
index 941a9bed5f169ed7ee4875a0b108fd102ea76665..8187adc7d15e39952e80889bb58a40d232905569 100644 (file)
@@ -65,7 +65,9 @@ extern "C" {
 
 namespace DEG {
 
-void DepsgraphNodeBuilder::build_scene(Scene *scene, eDepsNode_LinkedState_Type linked_state)
+void DepsgraphNodeBuilder::build_scene_layer(Scene *scene,
+                                             SceneLayer *scene_layer,
+                                             eDepsNode_LinkedState_Type linked_state)
 {
        /* scene ID block */
        add_id_node(&scene->id);
@@ -76,8 +78,9 @@ void DepsgraphNodeBuilder::build_scene(Scene *scene, eDepsNode_LinkedState_Type
        /* build subgraph for set, and link this in... */
        // XXX: depending on how this goes, that scene itself could probably store its
        //      own little partial depsgraph?
-       if (scene->set) {
-               build_scene(scene->set, DEG_ID_LINKED_VIA_SET);
+       if (scene->set != NULL) {
+               SceneLayer *set_scene_layer = BKE_scene_layer_from_scene_get(scene->set);
+               build_scene_layer(scene->set, set_scene_layer, DEG_ID_LINKED_VIA_SET);
        }
 
        /* Setup currently building context. */
@@ -85,12 +88,10 @@ void DepsgraphNodeBuilder::build_scene(Scene *scene, eDepsNode_LinkedState_Type
 
        /* scene objects */
        int select_color = 1;
-       for (SceneLayer *sl = (SceneLayer *)scene->render_layers.first; sl; sl = sl->next) {
-               for (Base *base = (Base *)sl->object_bases.first; base; base = base->next) {
-                       /* object itself */
-                       build_object(base->object, linked_state);
-                       base->object->select_color = select_color++;
-               }
+       LINKLIST_FOREACH(Base *, base, &scene_layer->object_bases) {
+               /* object itself */
+               build_object(base->object, linked_state);
+               base->object->select_color = select_color++;
        }
        if (scene->camera != NULL) {
                build_object(scene->camera, linked_state);
index 81636db0bcf0d031e7cef8d0c1d749360819e2b1..e433d3a92e2d7f768897b6f55b0b35f0c3eb30d3 100644 (file)
@@ -66,6 +66,7 @@ struct Object;
 struct bPoseChannel;
 struct bConstraint;
 struct Scene;
+struct SceneLayer;
 struct Tex;
 struct World;
 struct EffectorWeights;
@@ -186,7 +187,7 @@ struct DepsgraphRelationBuilder
                                      const DepsNodeHandle *handle,
                                      const char *description);
 
-       void build_scene(Scene *scene);
+       void build_scene_layer(Scene *scene, SceneLayer *scene_layer);
        void build_group(Object *object, Group *group);
        void build_object(Object *ob);
        void build_object_parent(Object *ob);
similarity index 89%
rename from source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
rename to source/blender/depsgraph/intern/builder/deg_builder_relations_scene_layer.cc
index af37decdbc7837bbcd2957e758a5cb1c6231229e..cbf4eddf13dbc4652e66820e88120338c92ef814 100644 (file)
@@ -68,23 +68,22 @@ extern "C" {
 
 namespace DEG {
 
-void DepsgraphRelationBuilder::build_scene(Scene *scene)
+void DepsgraphRelationBuilder::build_scene_layer(Scene *scene, SceneLayer *scene_layer)
 {
-       if (scene->set) {
-               build_scene(scene->set);
+       if (scene->set != NULL) {
+               SceneLayer *set_scene_layer = BKE_scene_layer_from_scene_get(scene->set);
+               build_scene_layer(scene->set, set_scene_layer);
        }
 
-       /* XXX store scene to access from DAG_get_scene */
        graph_->scene = scene;
+       graph_->scene_layer = scene_layer;
 
        /* Setup currently building context. */
        scene_ = scene;
 
        /* scene objects */
-       for (SceneLayer *sl = (SceneLayer *)scene->render_layers.first; sl; sl = sl->next) {
-               for (Base *base = (Base *)sl->object_bases.first; base; base = base->next) {
-                       build_object(base->object);
-               }
+       LINKLIST_FOREACH(Base *, base, &scene_layer->object_bases) {
+               build_object(base->object);
        }
        if (scene->camera != NULL) {
                build_object(scene->camera);
index 3caf7e5923f1cf8df82da05ae2535e0a85597e97..4a27dddf949f419aec91b2e13c08ba0702d95a98 100644 (file)
@@ -83,7 +83,8 @@ static DEG_EditorUpdateScenePreCb deg_editor_update_scene_pre_cb = NULL;
 Depsgraph::Depsgraph()
   : time_source(NULL),
     need_update(true),
-    scene(NULL)
+    scene(NULL),
+    scene_layer(NULL)
 {
        BLI_spin_init(&lock);
        id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
index 1b4dca569d70f283ffdc91e6d3918ca386c9d90b..b3ac345cef76341c9b037c1886ac2d675e4070e2 100644 (file)
@@ -47,6 +47,7 @@ struct GSet;
 struct PointerRNA;
 struct PropertyRNA;
 struct Scene;
+struct SceneLayer;
 
 namespace DEG {
 
@@ -174,8 +175,9 @@ struct Depsgraph {
         */
        SpinLock lock;
 
-       // XXX: additional stuff like eval contexts, mempools for allocating nodes from, etc.
-       Scene *scene; /* XXX: We really shouldn't do that, but it's required for shader preview. */
+       /* Scene and layer this dependency graph is built for. */
+       Scene *scene;
+       SceneLayer *scene_layer;
 };
 
 }  // namespace DEG
index c8c36646ade4d5f4eea85f776c621e1523e4e0ac..7083e6134dd7d18622fbb3a1c8052d98e065496d 100644 (file)
@@ -192,16 +192,16 @@ void DEG_add_special_eval_flag(Depsgraph *graph, ID *id, short flag)
 /* ******************** */
 /* Graph Building API's */
 
-/* Build depsgraph for the given scene, and dump results in given
+/* Build depsgraph for the given scene layer, and dump results in given
  * graph container.
  */
-/* XXX: assume that this is called from outside, given the current scene as
- * the "main" scene.
- */
-void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
+void DEG_graph_build_from_scene_layer(Depsgraph *graph,
+                                      Main *bmain,
+                                      Scene *scene,
+                                      SceneLayer *scene_layer)
 {
 #ifdef DEBUG_TIME
-       TIMEIT_START(DEG_graph_build_from_scene);
+       TIMEIT_START(DEG_graph_build_from_scene_layer);
 #endif
 
        DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
@@ -217,14 +217,16 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
        /* 1) Generate all the nodes in the graph first */
        DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph);
        node_builder.begin_build();
-       node_builder.build_scene(scene, DEG::DEG_ID_LINKED_DIRECTLY);
+       node_builder.build_scene_layer(scene,
+                                      scene_layer,
+                                      DEG::DEG_ID_LINKED_DIRECTLY);
 
        /* 2) Hook up relationships between operations - to determine evaluation
         *    order.
         */
        DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph);
        relation_builder.begin_build();
-       relation_builder.build_scene(scene);
+       relation_builder.build_scene_layer(scene, scene_layer);
        if (DEG_depsgraph_use_copy_on_write()) {
                relation_builder.build_copy_on_write_relations();
        }
@@ -252,7 +254,7 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
 #endif
 
 #ifdef DEBUG_TIME
-       TIMEIT_END(DEG_graph_build_from_scene);
+       TIMEIT_END(DEG_graph_build_from_scene_layer);
 #endif
 
        /* Relations are up to date. */
@@ -271,14 +273,17 @@ void DEG_graph_tag_relations_update(Depsgraph *graph)
 }
 
 /* Create or update relations in the specified graph. */
-void DEG_graph_relations_update(Depsgraph *graph, Main *bmain, Scene *scene)
+void DEG_graph_relations_update(Depsgraph *graph,
+                                Main *bmain,
+                                Scene *scene,
+                                SceneLayer *scene_layer)
 {
        DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)graph;
        if (!deg_graph->need_update) {
                /* Graph is up to date, nothing to do. */
                return;
        }
-       DEG_graph_build_from_scene(graph, bmain, scene);
+       DEG_graph_build_from_scene_layer(graph, bmain, scene, scene_layer);
 }
 
 /* Tag all relations for update. */
index dac084e4bad098b36cb04b7d0eaeda52a9a2a531..72d074dd5051edb0d214f33f3585e593ee337856 100644 (file)
@@ -66,11 +66,12 @@ bool DEG_debug_compare(const struct Depsgraph *graph1,
 
 bool DEG_debug_graph_relations_validate(Depsgraph *graph,
                                         Main *bmain,
-                                        Scene *scene)
+                                        Scene *scene,
+                                        SceneLayer *scene_layer)
 {
        Depsgraph *temp_depsgraph = DEG_graph_new();
        bool valid = true;
-       DEG_graph_build_from_scene(temp_depsgraph, bmain, scene);
+       DEG_graph_build_from_scene_layer(temp_depsgraph, bmain, scene, scene_layer);
        if (!DEG_debug_compare(temp_depsgraph, graph)) {
                fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n");
                BLI_assert(!"This should not happen!");
index 864db49f601f4ec05901d7b6a72bfd07dc5a1e84..8b451ccee32d5a471d8cf46a9643896240660fed 100644 (file)
@@ -91,11 +91,8 @@ Scene *DEG_get_evaluated_scene(Depsgraph *graph)
 
 SceneLayer *DEG_get_evaluated_scene_layer(Depsgraph *graph)
 {
-       Scene *scene = DEG_get_evaluated_scene(graph);
-       if (scene != NULL) {
-               return BKE_scene_layer_context_active_PLACEHOLDER(scene);
-       }
-       return NULL;
+       DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
+       return deg_graph->scene_layer;
 }
 
 Object *DEG_get_evaluated_object(Depsgraph *depsgraph, Object *object)
index f7219ce6846a37740126e2a1ca7485facd18edfd..51f1f38a9e989c7f350d09f05756c6e683d0da69 100644 (file)
@@ -168,7 +168,7 @@ bool ED_workspace_layout_cycle(
         struct bContext *C) ATTR_NONNULL();
 
 /* anim */
-void    ED_update_for_newframe(struct Main *bmain, struct Scene *scene, struct Depsgraph *depsgraph);
+void    ED_update_for_newframe(struct Main *bmain, struct Scene *scene, struct SceneLayer *scene_layer, struct Depsgraph *depsgraph);
 
 void    ED_refresh_viewport_fps(struct bContext *C);
 int            ED_screen_animation_play(struct bContext *C, int sync, int mode);
index ac24b106383dbe43aa3855af1b62ea404a29d92a..f6a23a03aa4a5af3bb0fb9cd124bdafe06422d91 100644 (file)
@@ -1765,7 +1765,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, sl, true);
                uint64_t customdata_mask_prev = scene->customdata_mask;
                scene->customdata_mask |= CD_MASK_MESH;
-               BKE_scene_graph_update_tagged(bmain->eval_ctx, depsgraph, bmain, scene);
+               BKE_scene_graph_update_tagged(bmain->eval_ctx, depsgraph, bmain, scene, sl);
                scene->customdata_mask = customdata_mask_prev;
        }
 
index 210d8351945e72f9f84b8434a0728b870d80cb95..c10604b0eddb346448673c5852aa44cdb895510a 100644 (file)
@@ -365,7 +365,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
        frame = surface->start_frame;
        orig_frame = scene->r.cfra;
        scene->r.cfra = (int)frame;
-       ED_update_for_newframe(job->bmain, scene, job->depsgraph);
+       ED_update_for_newframe(job->bmain, scene, job->scene_layer, job->depsgraph);
 
        /* Init surface */
        if (!dynamicPaint_createUVSurface(scene, surface, job->progress, job->do_update)) {
@@ -391,7 +391,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
 
                /* calculate a frame */
                scene->r.cfra = (int)frame;
-               ED_update_for_newframe(job->bmain, scene, job->depsgraph);
+               ED_update_for_newframe(job->bmain, scene, job->scene_layer, job->depsgraph);
                if (!dynamicPaint_calculateFrame(surface, job->eval_ctx, scene, cObject, frame)) {
                        job->success = 0;
                        return;
index a5e92802c6fccb93a2d269781ab5d21a8f53b51c..071dafe08bb33668af74e603a457d941d7972035 100644 (file)
@@ -409,7 +409,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
                /* Modifying the global scene isn't nice, but we can do it in 
                 * this part of the process before a threaded job is created */
                scene->r.cfra = (int)eval_time;
-               ED_update_for_newframe(CTX_data_main(C), scene, depsgraph);
+               ED_update_for_newframe(CTX_data_main(C), scene, sl, depsgraph);
                
                /* now scene data should be current according to animation system, so we fill the channels */
                
@@ -959,7 +959,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
 
        /* reset to original current frame */
        scene->r.cfra = origFrame;
-       ED_update_for_newframe(CTX_data_main(C), scene, depsgraph);
+       ED_update_for_newframe(CTX_data_main(C), scene, sl, depsgraph);
                
        /* ******** init domain object's matrix ******** */
        copy_m4_m4(domainMat, fsDomain->obmat);
index 61ff9264e95f8157e5f71d1d74e01905f7dfaeb3..3f2951b2a3ee8c1c889c380fcca25a7ab1ecd6c1 100644 (file)
@@ -101,6 +101,7 @@ static int render_break(void *rjv);
 typedef struct RenderJob {
        Main *main;
        Scene *scene;
+       SceneLayer *scene_layer;
        Scene *current_scene;
        /* TODO(sergey): Should not be needed once engine will have own
         * depsgraph and copy-on-write will be implemented.
@@ -295,6 +296,8 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s
 static int screen_render_exec(bContext *C, wmOperator *op)
 {
        Scene *scene = CTX_data_scene(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
+       Depsgraph *depsgraph = CTX_data_depsgraph(C);
        SceneRenderLayer *srl = NULL;
        Render *re;
        Image *ima;
@@ -342,7 +345,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
        RE_SetReports(re, NULL);
 
        // no redraw needed, we leave state as we entered it
-       ED_update_for_newframe(mainp, scene, CTX_data_depsgraph(C));
+       ED_update_for_newframe(mainp, scene, scene_layer, depsgraph);
 
        WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
 
@@ -656,7 +659,7 @@ static void render_endjob(void *rjv)
        if (rj->anim && !(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) {
                /* possible this fails of loading new file while rendering */
                if (G.main->wm.first) {
-                       ED_update_for_newframe(G.main, rj->scene, rj->depsgraph);
+                       ED_update_for_newframe(G.main, rj->scene, rj->scene_layer, rj->depsgraph);
                }
        }
        
@@ -919,6 +922,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
        rj->main = mainp;
        rj->scene = scene;
        rj->current_scene = rj->scene;
+       rj->scene_layer = CTX_data_scene_layer(C);
        /* TODO(sergey): Render engine should be using own depsgraph. */
        rj->depsgraph = CTX_data_depsgraph(C);
        rj->srl = srl;
index 03cffa5a3845bf3af82912786664529b3ca0240d..d436c562f1920a89a8b60592fbdc413e51fbb829 100644 (file)
@@ -812,8 +812,10 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
        }
 
        if (oglrender->timer) { /* exec will not have a timer */
+               Depsgraph *depsgraph = oglrender->depsgraph;
+               SceneLayer *scene_layer = oglrender->scene_layer;
                scene->r.cfra = oglrender->cfrao;
-               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, oglrender->depsgraph, bmain, scene);
+               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
 
                WM_event_remove_timer(oglrender->wm, oglrender->win, oglrender->timer);
        }
@@ -1013,6 +1015,8 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
        Main *bmain = CTX_data_main(C);
        OGLRender *oglrender = op->customdata;
        Scene *scene = oglrender->scene;
+       SceneLayer *scene_layer = oglrender->scene_layer;
+       Depsgraph *depsgraph = oglrender->depsgraph;
        char name[FILE_MAX];
        bool ok = false;
        const bool view_context = (oglrender->v3d != NULL);
@@ -1023,7 +1027,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
        if (CFRA < oglrender->nfra)
                CFRA++;
        while (CFRA < oglrender->nfra) {
-               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, oglrender->depsgraph, bmain, scene);
+               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
                CFRA++;
        }
 
@@ -1045,7 +1049,7 @@ static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
 
        WM_cursor_time(oglrender->win, scene->r.cfra);
 
-       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, oglrender->depsgraph, bmain, scene);
+       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
 
        if (view_context) {
                if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
index 84c843af020771336e64b5a76ba3f69386c08155..47eca1ccba3d745345d91a288693531a197144e9 100644 (file)
@@ -608,7 +608,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty
                /* TODO(sergey): Use proper flag for tagging here. */
                DEG_graph_id_tag_update(pr_main, depsgraph, &sce->id, 0);
                DEG_relations_tag_update(pr_main);
-               BKE_scene_graph_update_tagged(pr_main->eval_ctx, depsgraph, pr_main, sce);
+               BKE_scene_graph_update_tagged(pr_main->eval_ctx, depsgraph, pr_main, sce, scene_layer);
 
                return sce;
        }
index dca4cc77e5b0be98811f66195a36e3640f30c5f6..e68919aefaa7cb730cfa5a649404b2db53be02e5 100644 (file)
@@ -129,12 +129,12 @@ void ED_scene_changed_update(Main *bmain, bContext *C, Scene *scene_new, const b
        CTX_data_scene_set(C, scene_new);
        BKE_workspace_render_layer_set(CTX_wm_workspace(C), layer_new);
        BKE_scene_set_background(bmain, scene_new);
-       DEG_graph_relations_update(depsgraph, bmain, scene_new);
+       DEG_graph_relations_update(depsgraph, bmain, scene_new, layer_new);
        DEG_on_visible_update(bmain, false);
 
        ED_screen_update_after_scene_change(active_screen, scene_new, layer_new);
        ED_render_engine_changed(bmain);
-       ED_update_for_newframe(bmain, scene_new, depsgraph);
+       ED_update_for_newframe(bmain, scene_new, layer_new, depsgraph);
 
        /* complete redraw */
        WM_event_add_notifier(C, NC_WINDOW, NULL);
index 749a857fdaa672043735ec05927cbffe8e9cfca9..dfe2942868f937c13d23d81e1b1f6a2262f9b55d 100644 (file)
@@ -1727,7 +1727,7 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh)
 }
 
 /* results in fully updated anim system */
-void ED_update_for_newframe(Main *bmain, Scene *scene, struct Depsgraph *depsgraph)
+void ED_update_for_newframe(Main *bmain, Scene *scene, SceneLayer *scene_layer, struct Depsgraph *depsgraph)
 {
 #ifdef DURIAN_CAMERA_SWITCH
        void *camera = BKE_scene_camera_switch_find(scene);
@@ -1744,7 +1744,7 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, struct Depsgraph *depsgra
        ED_clip_update_frame(bmain, scene->r.cfra);
 
        /* this function applies the changes too */
-       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
 
        /* composite */
        if (scene->use_nodes && scene->nodetree)
index c02733d26bd6956a6329a98988c8a022cf4813f6..cb53de23983545ddec6d0b9b55b706f0db3ddb05 100644 (file)
@@ -3408,6 +3408,8 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
        if (screen->animtimer && screen->animtimer == event->customdata) {
                Main *bmain = CTX_data_main(C);
                Scene *scene = CTX_data_scene(C);
+               SceneLayer *scene_layer = CTX_data_scene_layer(C);
+               struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
                wmTimer *wt = screen->animtimer;
                ScreenAnimData *sad = wt->customdata;
                wmWindowManager *wm = CTX_wm_manager(C);
@@ -3518,7 +3520,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv
                }
                
                /* since we follow drawflags, we can't send notifier but tag regions ourselves */
-               ED_update_for_newframe(bmain, scene, CTX_data_depsgraph(C));
+               ED_update_for_newframe(bmain, scene, scene_layer, depsgraph);
 
                for (window = wm->windows.first; window; window = window->next) {
                        const bScreen *win_screen = WM_window_get_active_screen(window);
index 0d6e0cf8e89822422ecf2b84829b6ed851759811..4fed7c4467ed43d015ee2ba87e1c22c5f44eba34 100644 (file)
@@ -311,6 +311,7 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
        struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
        int oldfra = scene->r.cfra;
        int cfra;
@@ -319,11 +320,11 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
 
        for (cfra = (scene->r.sfra > 0) ? (scene->r.sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) {
                scene->r.cfra = cfra;
-               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
        }
 
        scene->r.cfra = oldfra;
-       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
 
        return OPERATOR_FINISHED;
 }
index ed215a84dc7d23b8dc55df718ec4ed62f491f42a..922cae1320d4ae18e221a61328c37f4ecef2c279 100644 (file)
@@ -5559,7 +5559,7 @@ static void set_trans_object_base_flags(TransInfo *t)
        BKE_scene_base_flag_to_objects(t->scene_layer);
 
        /* Make sure depsgraph is here. */
-       DEG_graph_relations_update(depsgraph, bmain, scene);
+       DEG_graph_relations_update(depsgraph, bmain, scene, sl);
 
        /* handle pending update events, otherwise they got copied below */
        EvaluationContext eval_ctx;
@@ -5696,7 +5696,7 @@ static int count_proportional_objects(TransInfo *t)
        
 
        /* all recalc flags get flushed to all layers, so a layer flip later on works fine */
-       DEG_graph_relations_update(depsgraph, bmain, scene);
+       DEG_graph_relations_update(depsgraph, bmain, scene, sl);
        DEG_graph_flush_update(bmain, depsgraph);
 
        /* and we store them temporal in base (only used for transform code) */
index 6f79b90fd8a9881be0c116da1fde9c29194bb865..0424ed4bb164bcc7fe4e51910821739e2b995131 100644 (file)
@@ -972,7 +972,8 @@ Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render)
 #endif
 
        Render *freestyle_render = RE_NewSceneRender(freestyle_scene);
-       DEG_graph_relations_update(freestyle_depsgraph, freestyle_bmain, freestyle_scene);
+       SceneLayer *scene_layer = (SceneLayer *)freestyle_scene->render_layers.first;
+       DEG_graph_relations_update(freestyle_depsgraph, freestyle_bmain, freestyle_scene, scene_layer);
        freestyle_render->depsgraph = freestyle_depsgraph;
 
        RE_RenderFreestyleStrokes(freestyle_render, freestyle_bmain, freestyle_scene,
index 78afba0e426eeabc2f81c39032001e9bd2742396..3cdb643388227f1e7535c5a1e26fc1963ee57190 100644 (file)
@@ -90,7 +90,11 @@ static void rna_Scene_frame_set(Scene *scene, Main *bmain, int frame, float subf
             scene_layer = scene_layer->next)
        {
                Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer, true);
-               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+               BKE_scene_graph_update_for_newframe(bmain->eval_ctx,
+                                                   depsgraph,
+                                                   bmain,
+                                                   scene,
+                                                   scene_layer);
        }
 
 #ifdef WITH_PYTHON
@@ -136,7 +140,11 @@ static void rna_Scene_update_tagged(Scene *scene, Main *bmain)
             scene_layer = scene_layer->next)
        {
                Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer, true);
-               BKE_scene_graph_update_tagged(bmain->eval_ctx, depsgraph, bmain, scene);
+               BKE_scene_graph_update_tagged(bmain->eval_ctx,
+                                             depsgraph,
+                                             bmain,
+                                             scene,
+                                             scene_layer);
        }
 
 #ifdef WITH_PYTHON
index d7737381c460831eef49ab7d1e04ae8dba81c303..608c182bd7b8782678cd1e5b1a086529c4cffcfd 100644 (file)
@@ -5220,7 +5220,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
        
        /* applies changes fully */
        if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) {
-               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene);
+               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene, NULL);
                render_update_anim_renderdata(re, &re->scene->r);
        }
        
@@ -5392,7 +5392,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la
        
        /* applies changes fully */
        scene->r.cfra += timeoffset;
-       BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene);
+       BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene, NULL);
        
        /* if no camera, viewmat should have been set! */
        if (camera) {
index 28c0c1cbf14ccf7e9103b854abe95d420568cdad..61f59eace89b527f1ecc9b114b4044f0f6ccde34 100644 (file)
@@ -622,7 +622,7 @@ void RE_engine_frame_set(RenderEngine *engine, int frame, float subframe)
        BPy_BEGIN_ALLOW_THREADS;
 #endif
 
-       BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, scene);
+       BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, scene, NULL);
 
 #ifdef WITH_PYTHON
        BPy_END_ALLOW_THREADS;
@@ -657,7 +657,7 @@ int RE_engine_render(Render *re, int do_all)
        /* update animation here so any render layer animation is applied before
         * creating the render result */
        if ((re->r.scemode & (R_NO_FRAME_UPDATE | R_BUTS_PREVIEW)) == 0) {
-               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene);
+               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene, NULL);
                render_update_anim_renderdata(re, &re->scene->r);
        }
 
index cac17dcd86e49981bf3c4e472cdc1c2e31306ac7..080e68d813ef559edb88c21ebb3ab7ad10418376 100644 (file)
@@ -1748,7 +1748,7 @@ static void do_render_blur_3d(Render *re)
        
        /* make sure motion blur changes get reset to current frame */
        if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_BUTS_PREVIEW|R_VIEWPORT_PREVIEW))==0) {
-               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene);
+               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene, NULL);
        }
        
        /* weak... the display callback wants an active renderlayer pointer... */
@@ -2635,7 +2635,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
                                R.i.cfra = re->i.cfra;
                                
                                if (update_newframe)
-                                       BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene);
+                                       BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, re->main, re->scene, NULL);
                                
                                if (re->r.scemode & R_FULL_SAMPLE)
                                        do_merge_fullsample(re, ntree);
@@ -3700,7 +3700,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
 
                        if (nfra != scene->r.cfra) {
                                /* Skip this frame, but update for physics and particles system. */
-                               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, bmain, scene);
+                               BKE_scene_graph_update_for_newframe(re->eval_ctx, re->depsgraph, bmain, scene, NULL);
                                continue;
                        }
                        else
index 7701e501591f6bc5ea3039429fbdcb4a1b3a29fb..ffe417487d7dcec3599f0778c5ef73f243140b7b 100644 (file)
@@ -389,8 +389,8 @@ void wm_event_do_notifiers(bContext *C)
                                }
                        }
                        if (ELEM(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_WM)) {
-                               SceneLayer *sl = CTX_data_scene_layer(C);
-                               ED_info_stats_clear(sl);
+                               SceneLayer *scene_layer = CTX_data_scene_layer(C);
+                               ED_info_stats_clear(scene_layer);
                                WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL);
                        }
                }
@@ -400,9 +400,10 @@ void wm_event_do_notifiers(bContext *C)
                         * collide (happens on slow scenes), BKE_scene_graph_update_for_newframe can be called
                         * twice which can depgraph update the same object at once */
                        if (G.is_rendering == false) {
-
                                /* depsgraph gets called, might send more notifiers */
-                               ED_update_for_newframe(CTX_data_main(C), scene, CTX_data_depsgraph(C));
+                               SceneLayer *scene_layer = CTX_data_scene_layer(C);
+                               Depsgraph *depsgraph = CTX_data_depsgraph(C);
+                               ED_update_for_newframe(CTX_data_main(C), scene, scene_layer, depsgraph);
                        }
                }
        }
@@ -2599,7 +2600,7 @@ void wm_event_do_handlers(bContext *C)
                        wm_event_free_all(win);
                else {
                        Scene *scene = WM_window_get_active_scene(win);
-                       
+
                        if (scene) {
                                int is_playing_sound = BKE_sound_scene_playing(scene);
                                
@@ -2622,7 +2623,9 @@ void wm_event_do_handlers(bContext *C)
                                                        int ncfra = time * (float)FPS + 0.5f;
                                                        if (ncfra != scene->r.cfra) {
                                                                scene->r.cfra = ncfra;
-                                                               ED_update_for_newframe(CTX_data_main(C), scene, CTX_data_depsgraph(C));
+                                                               SceneLayer *scene_layer = CTX_data_scene_layer(C);
+                                                               Depsgraph *depsgraph = CTX_data_depsgraph(C);
+                                                               ED_update_for_newframe(CTX_data_main(C), scene, scene_layer, depsgraph);
                                                                WM_event_add_notifier(C, NC_WINDOW, NULL);
                                                        }
                                                }
index ee2d9553c6039fad0f0d52ccb9a38e14592f09c7..d98d66f178d877c728af65ccba957e399eb79941 100644 (file)
@@ -3240,7 +3240,8 @@ static const EnumPropertyItem redraw_timer_type_items[] = {
 
 
 static void redraw_timer_step(
-        bContext *C, Main *bmain, Scene *scene, struct Depsgraph *depsgraph,
+        bContext *C, Main *bmain, Scene *scene, SceneLayer *scene_layer,
+        struct Depsgraph *depsgraph,
         wmWindow *win, ScrArea *sa, ARegion *ar,
         const int type, const int cfra)
 {
@@ -3287,7 +3288,7 @@ static void redraw_timer_step(
        }
        else if (type == eRTAnimationStep) {
                scene->r.cfra += (cfra == scene->r.cfra) ? 1 : -1;
-               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+               BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
        }
        else if (type == eRTAnimationPlay) {
                /* play anim, return on same frame as started with */
@@ -3299,7 +3300,7 @@ static void redraw_timer_step(
                        if (scene->r.cfra > scene->r.efra)
                                scene->r.cfra = scene->r.sfra;
 
-                       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene);
+                       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, depsgraph, bmain, scene, scene_layer);
                        redraw_timer_window_swap(C);
                }
        }
@@ -3313,6 +3314,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
+       SceneLayer *scene_layer = CTX_data_scene_layer(C);
        wmWindow *win = CTX_wm_window(C);
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = CTX_wm_region(C);
@@ -3330,7 +3332,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op)
        time_start = PIL_check_seconds_timer();
 
        for (a = 0; a < iter; a++) {
-               redraw_timer_step(C, bmain, scene, depsgraph, win, sa, ar, type, cfra);
+               redraw_timer_step(C, bmain, scene, scene_layer, depsgraph, win, sa, ar, type, cfra);
                iter_steps += 1;
 
                if (time_limit != 0.0) {
index c3f355f3937869cf95c2cd605ff93aea781872c3..3b5fd82e096223096f751144fe0ad0b5b8adf7a7 100644 (file)
@@ -91,6 +91,7 @@
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_debug.h"
 
 #include "creator_intern.h"  /* own include */
 
@@ -441,7 +442,12 @@ static void render_set_depgraph(bContext *C, Render *re)
         */
        SceneLayer *scene_layer = scene->render_layers.first;
        Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, scene_layer, true);
-       DEG_graph_relations_update(depsgraph, bmain, scene);
+       DEG_graph_relations_update(depsgraph, bmain, scene, scene_layer);
+       {
+               FILE *stream = fopen("/home/sergey/deg.dot", "w");
+               DEG_debug_graphviz(depsgraph, stream, "", false);
+               fclose(stream);
+       }
        DEG_graph_on_visible_update(bmain, depsgraph);
 
        RE_SetDepsgraph(re, depsgraph);
index b5ef1a194e91faba54e6d341878f03c1ff3d361d..2e4d95f6f60ff0277ac49b6de4d685b1463dc0aa 100644 (file)
@@ -16,9 +16,9 @@ extern "C" {
 class TestableAbcExporter : public AbcExporter {
 public:
        TestableAbcExporter(Main *bmain, EvaluationContext *eval_ctx,
-                           Scene *scene, Depsgraph *depsgraph,
+                           Scene *scene, SceneLayer *scene_layer, Depsgraph *depsgraph,
                            const char *filename, ExportSettings &settings)
-           : AbcExporter(bmain, eval_ctx, scene, depsgraph, filename, settings)
+           : AbcExporter(bmain, eval_ctx, scene, scene_layer, depsgraph, filename, settings)
        {
        }
 
@@ -73,7 +73,8 @@ protected:
        // Call after setting up the settings.
        void createExporter()
        {
-               exporter = new TestableAbcExporter(bmain, &eval_ctx, &scene, depsgraph, "somefile.abc", settings);
+               SceneLayer *scene_layer = (SceneLayer *)scene.render_layers.first;
+               exporter = new TestableAbcExporter(bmain, &eval_ctx, &scene, scene_layer, depsgraph, "somefile.abc", settings);
        }
 };