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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-04-12 10:47:51 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-04-12 12:05:18 +0300
commit15698f99070f4d196dbfbac63d3634019c4d1ca9 (patch)
tree2776a25ee6f91cede1c197add7b0ee3afa8e9a7e /source/blender/depsgraph/intern/depsgraph_query.cc
parent18c7575f93aa73f3a25290a97950d4eb6d37f94c (diff)
Depsgraph: Avoid relations build time scene datablock expansion
Quite straightforward implementation, allows us to remove all the cherry-picking update of specified scene/view layer/collection fields. Makes it possible to use generic function to update scene. The tricky part is that we need to know view layer pointer before the whole evaluation starts. So we actually expand scene at initialization of evaluation. context. This is still a bit of an exceptional case, but at least we still avoid dangerous cherry-picking update.
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_query.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc31
1 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 63c9aa1407a..4e70e56ae71 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -45,6 +45,7 @@ extern "C" {
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
+#include "intern/eval/deg_eval_copy_on_write.h"
#include "intern/depsgraph_intern.h"
#include "intern/nodes/deg_node_id.h"
@@ -77,20 +78,44 @@ short DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
Scene *DEG_get_evaluated_scene(const Depsgraph *graph)
{
- const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ const DEG::Depsgraph *deg_graph =
+ reinterpret_cast<const DEG::Depsgraph *>(graph);
Scene *scene_orig = deg_graph->scene;
- return reinterpret_cast<Scene *>(deg_graph->get_cow_id(&scene_orig->id));
+ Scene *scene_cow =
+ reinterpret_cast<Scene *>(deg_graph->get_cow_id(&scene_orig->id));
+ /* TODO(sergey): Shall we expand datablock here? Or is it OK to assume
+ * that calleer is OK with just a pointer in case scene is not up[dated
+ * yet?
+ */
+ return scene_cow;
}
ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph)
{
- const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ const DEG::Depsgraph *deg_graph =
+ reinterpret_cast<const DEG::Depsgraph *>(graph);
Scene *scene_cow = DEG_get_evaluated_scene(graph);
+ /* We update copy-on-write scene in the following cases:
+ * - It was not expanded yet.
+ * - It was tagged for update of CoW component.
+ * This allows us to have proper view layer pointer.
+ */
+ if (DEG_depsgraph_use_copy_on_write() &&
+ (!DEG::deg_copy_on_write_is_expanded(&scene_cow->id) ||
+ scene_cow->id.recalc & ID_RECALC_COPY_ON_WRITE))
+ {
+ const DEG::IDDepsNode *id_node =
+ deg_graph->find_id_node(&deg_graph->scene->id);
+ DEG::deg_update_copy_on_write_datablock(deg_graph, id_node);
+ }
+ /* Do name-based lookup. */
+ /* TODO(sergey): Can this be optimized? */
ViewLayer *view_layer_orig = deg_graph->view_layer;
ViewLayer *view_layer_cow =
(ViewLayer *)BLI_findstring(&scene_cow->view_layers,
view_layer_orig->name,
offsetof(ViewLayer, name));
+ BLI_assert(view_layer_cow != NULL);
return view_layer_cow;
}