diff options
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.cc | 3 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.h | 5 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_build.cc | 3 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query.cc | 4 |
4 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index c90279b0e90..a4aff826af4 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -102,7 +102,8 @@ Depsgraph::Depsgraph(Scene *scene, scene(scene), view_layer(view_layer), mode(mode), - ctime(BKE_scene_frame_get(scene)) + ctime(BKE_scene_frame_get(scene)), + scene_cow(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 e10f7d5b115..284dc28031b 100644 --- a/source/blender/depsgraph/intern/depsgraph.h +++ b/source/blender/depsgraph/intern/depsgraph.h @@ -197,6 +197,11 @@ struct Depsgraph { /* Time at which dependency graph is being or was last evaluated. */ float ctime; + + /* Evaluated version of datablocks we access a lot. + * Stored here to save us form doing hash lookup. + */ + Scene *scene_cow; }; } // namespace DEG diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index ecd3d5361f8..0a958fa67d3 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -260,6 +260,9 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph, /* Relations are up to date. */ deg_graph->need_update = false; + /* Store pointers to commonly used valuated datablocks. */ + deg_graph->scene_cow = (Scene *)deg_graph->get_cow_id(°_graph->scene->id); + if (need_on_visible_update) { DEG_graph_on_visible_update(bmain, graph); } diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index 63eb1f18281..8f4bf2d082e 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -105,9 +105,7 @@ Scene *DEG_get_evaluated_scene(const Depsgraph *graph) { const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph); - Scene *scene_orig = deg_graph->scene; - Scene *scene_cow = - reinterpret_cast<Scene *>(deg_graph->get_cow_id(&scene_orig->id)); + Scene *scene_cow = deg_graph->scene_cow; /* 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? |