diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-09 13:20:17 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-09 13:20:17 +0300 |
commit | d325e6f0e845d710abe4847a57be8e30920911a9 (patch) | |
tree | 13138d409459bbe7e223833a8f6a5000437585e6 /source/blender/depsgraph | |
parent | c99481b6320a77e4793c812403f7d37dfc2d5ced (diff) |
Depsgraph: Make dependency graph to be built from scene layer
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.
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r-- | source/blender/depsgraph/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph_build.h | 11 | ||||
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph_debug.h | 6 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes.h | 5 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_nodes_scene_layer.cc (renamed from source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc) | 19 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_relations.h | 3 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/builder/deg_builder_relations_scene_layer.cc (renamed from source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc) | 15 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.cc | 3 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.h | 6 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_build.cc | 27 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_debug.cc | 5 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query.cc | 7 |
12 files changed, 62 insertions, 49 deletions
diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index eae3e402850..64fa5ddfb3d 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -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 diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index 06202b6196e..e328d3d9e8c 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -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); diff --git a/source/blender/depsgraph/DEG_depsgraph_debug.h b/source/blender/depsgraph/DEG_depsgraph_debug.h index 7546f1d9018..fd6dff4c973 100644 --- a/source/blender/depsgraph/DEG_depsgraph_debug.h +++ b/source/blender/depsgraph/DEG_depsgraph_debug.h @@ -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); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h index 40d6a56e789..4a311cec4bd 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h @@ -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); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene_layer.cc index 941a9bed5f1..8187adc7d15 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene_layer.cc @@ -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); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 81636db0bcf..e433d3a92e2 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -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); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene_layer.cc index af37decdbc7..cbf4eddf13d 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene_layer.cc @@ -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); diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index 3caf7e5923f..4a27dddf949 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -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"); diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h index 1b4dca569d7..b3ac345cef7 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -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 diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index c8c36646ade..7083e6134dd 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -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. */ diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index dac084e4bad..72d074dd505 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -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!"); diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index 864db49f601..8b451ccee32 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -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) |