[Bf-blender-cvs] [7a4b0ff3581] blender2.8: Depsgraph: Begin concept of active dependency graph

Sergey Sharybin noreply at git.blender.org
Thu May 31 18:11:11 CEST 2018


Commit: 7a4b0ff358121397519873123fa77a7cc00974bd
Author: Sergey Sharybin
Date:   Thu May 31 12:57:21 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7a4b0ff358121397519873123fa77a7cc00974bd

Depsgraph: Begin concept of active dependency graph

When active dependency graph is evaluated, it will apply animation,
drivers and scalar evaluation data (such as object matrix) to an
original datablock. This way operators and tools can easily read
data from original datablock.

This will simplify porting them to copy-on-write, and solve issues
when some operator will allocate new datablock based on original one,
and will want to read data from it.

===================================================================

M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph.cc
M	source/blender/depsgraph/intern/depsgraph.h

===================================================================

diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index fbd267924a9..2071342dfa0 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -229,6 +229,12 @@ typedef void (*DEG_EditorUpdateSceneCb)(
 void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func,
                                DEG_EditorUpdateSceneCb scene_func);
 
+/* Evaluation  ----------------------------------- */
+
+bool DEG_is_active(const struct Depsgraph *depsgraph);
+void DEG_make_active(struct Depsgraph *depsgraph);
+void DEG_make_inactive(struct Depsgraph *depsgraph);
+
 /* Evaluation Debug ------------------------------ */
 
 void DEG_debug_print_begin(struct Depsgraph *depsgraph);
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index a247b458cc7..96e89449d42 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -92,7 +92,8 @@ Depsgraph::Depsgraph(Scene *scene,
     view_layer(view_layer),
     mode(mode),
     ctime(BKE_scene_frame_get(scene)),
-    scene_cow(NULL)
+    scene_cow(NULL),
+	is_active(false)
 {
 	BLI_spin_init(&lock);
 	id_hash = BLI_ghash_ptr_new("Depsgraph id hash");
@@ -588,6 +589,34 @@ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func,
 	DEG::deg_editor_update_scene_cb = scene_func;
 }
 
+bool DEG_is_active(const struct Depsgraph *depsgraph)
+{
+	if (depsgraph == NULL) {
+		/* Happens for such cases as work object in what_does_obaction(),
+		 * and sine render pipeline parts. Shouldn't really be accepting
+		 * NULL depsgraph, but is quite hard to get proper one in those
+		 * cases.
+		 */
+		return false;
+	}
+	const DEG::Depsgraph *deg_graph =
+	        reinterpret_cast<const DEG::Depsgraph *>(depsgraph);
+	return deg_graph->is_active;
+}
+
+void DEG_make_active(struct Depsgraph *depsgraph)
+{
+	DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+	deg_graph->is_active = true;
+	/* TODO(sergey): Copy data from evaluated state to original. */
+}
+
+void DEG_make_inactive(struct Depsgraph *depsgraph)
+{
+	DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+	deg_graph->is_active = false;
+}
+
 /* Evaluation and debug */
 
 static DEG::string depsgraph_name_for_logging(struct Depsgraph *depsgraph)
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index a368158a6c4..3c1233cd5bb 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -210,6 +210,16 @@ struct Depsgraph {
 	 */
 	Scene *scene_cow;
 
+	/* Active dependency graph is a dependency graph which is used by the
+	 * currently active window. When dependency graph is active, it is allowed
+	 * for evaluation functions to write animation f-curve result, drivers
+	 * result and other selective things (object matrix?) to original object.
+	 *
+	 * This way we simplify operators, which don't need to worry about where
+	 * to read stuff from.
+	 */
+	bool is_active;
+
 	/* NITE: Corresponds to G_DEBUG_DEPSGRAPH_* flags. */
 	int debug_flags;
 	string debug_name;



More information about the Bf-blender-cvs mailing list