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:
authorBastien Montagne <b.mont29@gmail.com>2020-03-17 13:24:37 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-03-17 13:24:37 +0300
commit2ba3e6a02e5c15b5532d82e64cc6214149272e8e (patch)
tree9a3a5afca921dad891220e49694d9bfec8385768 /source/blender/depsgraph/intern/depsgraph.cc
parent90ce708ef0b086c4cd148996cb039cd7ece21457 (diff)
Depsgraph: Adds helpers to extract/restore despgraphs in a given Main.
Extract will steal all depsgraphs currently stored in given bmain, and restore will put them back in place, using scene and viewlayers as keys. Preliminary work for undo-speedup. Part of T60695/D6580.
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index ce6797939b5..a19a2958f28 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -285,6 +285,29 @@ Depsgraph *DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEval
return reinterpret_cast<Depsgraph *>(deg_depsgraph);
}
+/* Replace the "owner" pointers (currently Main/Scene/ViewLayer) of this depsgraph.
+ * Used during undo steps when we do want to re-use the old depsgraph data as much as possible. */
+void DEG_graph_replace_owners(struct Depsgraph *depsgraph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
+{
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+
+ const bool do_update_register = deg_graph->bmain != bmain;
+ if (do_update_register && deg_graph->bmain != NULL) {
+ DEG::unregister_graph(deg_graph);
+ }
+
+ deg_graph->bmain = bmain;
+ deg_graph->scene = scene;
+ deg_graph->view_layer = view_layer;
+
+ if (do_update_register) {
+ DEG::register_graph(deg_graph);
+ }
+}
+
/* Free graph's contents and graph itself */
void DEG_graph_free(Depsgraph *graph)
{