diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-03-17 13:24:37 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-03-17 13:24:37 +0300 |
commit | 2ba3e6a02e5c15b5532d82e64cc6214149272e8e (patch) | |
tree | 9a3a5afca921dad891220e49694d9bfec8385768 /source/blender/depsgraph | |
parent | 90ce708ef0b086c4cd148996cb039cd7ece21457 (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')
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph.h | 5 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph.cc | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h index d5a93d21b99..c94a8876ab0 100644 --- a/source/blender/depsgraph/DEG_depsgraph.h +++ b/source/blender/depsgraph/DEG_depsgraph.h @@ -92,6 +92,11 @@ Depsgraph *DEG_graph_new(struct Main *bmain, struct ViewLayer *view_layer, eEvaluationMode mode); +void DEG_graph_replace_owners(struct Depsgraph *depsgraph, + struct Main *bmain, + struct Scene *scene, + struct ViewLayer *view_layer); + /* Free Depsgraph itself and all its data */ void DEG_graph_free(Depsgraph *graph); 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) { |