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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-04-06 10:17:53 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-04-13 15:17:22 +0300
commit340bfdef2e424c59e85785c1660db805b3255882 (patch)
treed4677eef333ecd0d9d07e8d87b7d31aa254bf02d /source/blender/depsgraph/intern
parent5d7952d9c75d087b551ab95dff90ee2f7f636417 (diff)
Depsgraph: store mode and time in depsgraph, add view layer / scene accessors.
Scene, view layer and mode are now set in the constructor and never changed. Time is updated on frame changes to indicate which frame is being or has been evaluated last. This is a step towards making EvaluationContext obsolete. Differential Revision: https://developer.blender.org/D3144
Diffstat (limited to 'source/blender/depsgraph/intern')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc4
-rw-r--r--source/blender/depsgraph/intern/depsgraph.cc23
-rw-r--r--source/blender/depsgraph/intern/depsgraph.h12
-rw-r--r--source/blender/depsgraph/intern/depsgraph_debug.cc5
-rw-r--r--source/blender/depsgraph/intern/depsgraph_eval.cc4
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc25
-rw-r--r--source/blender/depsgraph/intern/depsgraph_tag.cc19
7 files changed, 61 insertions, 31 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
index 339046dfac0..85f465efb82 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_view_layer.cc
@@ -127,8 +127,8 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la
build_view_layer(scene->set, set_view_layer);
}
- graph_->scene = scene;
- graph_->view_layer = view_layer;
+ BLI_assert(graph_->scene == scene);
+ BLI_assert(graph_->view_layer == view_layer);
}
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 3500f38467d..a87358187f2 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -49,6 +49,8 @@ extern "C" {
#include "DNA_sequence_types.h"
#include "RNA_access.h"
+
+#include "BKE_scene.h"
}
#include <algorithm>
@@ -92,11 +94,15 @@ static void remove_from_vector(vector<T> *vector, const T& value)
vector->end());
}
-Depsgraph::Depsgraph()
+Depsgraph::Depsgraph(Scene *scene,
+ ViewLayer *view_layer,
+ eEvaluationMode mode)
: time_source(NULL),
need_update(true),
- scene(NULL),
- view_layer(NULL)
+ scene(scene),
+ view_layer(view_layer),
+ mode(mode),
+ ctime(BKE_scene_frame_get(scene))
{
BLI_spin_init(&lock);
id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
@@ -559,9 +565,14 @@ string deg_color_end(void)
/* Public Graph API */
/* Initialize a new Depsgraph */
-Depsgraph *DEG_graph_new()
-{
- DEG::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW(DEG::Depsgraph);
+Depsgraph *DEG_graph_new(Scene *scene,
+ ViewLayer *view_layer,
+ eEvaluationMode mode)
+{
+ DEG::Depsgraph *deg_depsgraph = OBJECT_GUARDED_NEW(DEG::Depsgraph,
+ scene,
+ view_layer,
+ mode);
return reinterpret_cast<Depsgraph *>(deg_depsgraph);
}
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 985991e91e3..9fa6b38166d 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -38,6 +38,8 @@
#include "BLI_threads.h" /* for SpinLock */
+#include "DEG_depsgraph.h"
+
#include "intern/depsgraph_types.h"
struct ID;
@@ -100,7 +102,9 @@ struct Depsgraph {
typedef vector<OperationDepsNode *> OperationNodes;
typedef vector<IDDepsNode *> IDDepsNodes;
- Depsgraph();
+ Depsgraph(Scene *scene,
+ ViewLayer *view_layer,
+ eEvaluationMode mode);
~Depsgraph();
/**
@@ -187,9 +191,13 @@ struct Depsgraph {
*/
SpinLock lock;
- /* Scene and layer this dependency graph is built for. */
+ /* Scene, layer, mode this dependency graph is built for. */
Scene *scene;
ViewLayer *view_layer;
+ eEvaluationMode mode;
+
+ /* Time at which dependency graph is being or was last evaluated. */
+ float ctime;
};
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index e8d166532ad..78b1c6f88c5 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -37,9 +37,12 @@ extern "C" {
#include "DNA_scene_types.h"
} /* extern "C" */
+#include "DNA_object_types.h"
+
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_debug.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "intern/depsgraph_intern.h"
#include "intern/nodes/deg_node_id.h"
@@ -72,7 +75,7 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph,
Scene *scene,
ViewLayer *view_layer)
{
- Depsgraph *temp_depsgraph = DEG_graph_new();
+ Depsgraph *temp_depsgraph = DEG_graph_new(scene, view_layer, DEG_get_mode(graph));
bool valid = true;
DEG_graph_build_from_view_layer(temp_depsgraph, bmain, scene, view_layer);
if (!DEG_debug_compare(temp_depsgraph, graph)) {
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index 0b3e4fd8db9..d50e55e4cfb 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -134,9 +134,10 @@ void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx,
Depsgraph *graph)
{
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
+ deg_graph->ctime = BKE_scene_frame_get(deg_graph->scene);
/* Update time on primary timesource. */
DEG::TimeSourceDepsNode *tsrc = deg_graph->find_time_source();
- tsrc->cfra = BKE_scene_frame_get(deg_graph->scene);
+ tsrc->cfra = deg_graph->ctime;
DEG::deg_evaluate_on_refresh(eval_ctx, deg_graph);
}
@@ -147,6 +148,7 @@ void DEG_evaluate_on_framechange(EvaluationContext *eval_ctx,
float ctime)
{
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
+ deg_graph->ctime = ctime;
/* Update time on primary timesource. */
DEG::TimeSourceDepsNode *tsrc = deg_graph->find_time_source();
tsrc->cfra = ctime;
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 4e70e56ae71..6f0ba26c8f7 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -49,6 +49,31 @@ extern "C" {
#include "intern/depsgraph_intern.h"
#include "intern/nodes/deg_node_id.h"
+struct Scene *DEG_get_input_scene(const Depsgraph *graph)
+{
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ return deg_graph->scene;
+}
+
+struct ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph)
+{
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ return deg_graph->view_layer;
+}
+
+eEvaluationMode DEG_get_mode(const Depsgraph *graph)
+{
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ return deg_graph->mode;
+}
+
+float DEG_get_ctime(const Depsgraph *graph)
+{
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ return deg_graph->ctime;
+}
+
+
bool DEG_id_type_tagged(Main *bmain, short id_type)
{
return bmain->id_tag_update[BKE_idcode_to_index(id_type)] != 0;
diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc
index d1de12f4591..6a6ebd1be44 100644
--- a/source/blender/depsgraph/intern/depsgraph_tag.cc
+++ b/source/blender/depsgraph/intern/depsgraph_tag.cc
@@ -425,20 +425,6 @@ void deg_graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag)
id_tag_update_ntree_special(bmain, graph, id, flag);
}
-/* TODO(sergey): Consider storing scene and view layer at depsgraph allocation
- * time.
- */
-void deg_ensure_scene_view_layer(Depsgraph *graph,
- Scene *scene,
- ViewLayer *view_layer)
-{
- if (!graph->need_update) {
- return;
- }
- graph->scene = scene;
- graph->view_layer = view_layer;
-}
-
void deg_id_tag_update(Main *bmain, ID *id, int flag)
{
deg_graph_id_tag_update(bmain, NULL, id, flag);
@@ -449,11 +435,6 @@ void deg_id_tag_update(Main *bmain, ID *id, int flag)
view_layer,
false);
if (depsgraph != NULL) {
- /* Make sure depsgraph is pointing to a correct scene and
- * view layer. This is mainly required in cases when depsgraph
- * was not built yet.
- */
- deg_ensure_scene_view_layer(depsgraph, scene, view_layer);
deg_graph_id_tag_update(bmain, depsgraph, id, flag);
}
}