[Bf-blender-cvs] [05243a633a7] blender2.8: Depsgraph: Store Scene in depsgraph struct

Dalai Felinto noreply at git.blender.org
Tue Apr 25 18:07:45 CEST 2017


Commit: 05243a633a7ccf4abf75e3a88d67e2e5cc02a1a6
Author: Dalai Felinto
Date:   Tue Apr 25 17:46:23 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB05243a633a7ccf4abf75e3a88d67e2e5cc02a1a6

Depsgraph: Store Scene in depsgraph struct

This way we can retrieve the scene from depsgraph that were not created from a G.main (e.g., when doing material thumbnail preview render).

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

M	source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_query.cc

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
index 3a007c4153a..748a36d2c4d 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
@@ -70,6 +70,9 @@ namespace DEG {
 
 void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
 {
+	/* XXX store scene to access from DAG_get_scene */
+	m_graph->scene = scene;
+
 	if (scene->set) {
 		build_scene(bmain, scene->set);
 	}
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index a8548ebaa4e..035abcf0ba1 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -45,6 +45,7 @@ struct GHash;
 struct GSet;
 struct PointerRNA;
 struct PropertyRNA;
+struct Scene;
 
 namespace DEG {
 
@@ -173,6 +174,8 @@ struct Depsgraph {
 	SpinLock lock;
 
 	// XXX: additional stuff like eval contexts, mempools for allocating nodes from, etc.
+
+	Scene *scene; /* XXX: We really shouldn't do that, but it's required for shader preview */
 };
 
 }  // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 952a4af0208..6193fd3d7cf 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -76,14 +76,8 @@ short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
 
 Scene *DAG_get_scene(Depsgraph *graph)
 {
-	Main *bmain = G.main;
-	LINKLIST_FOREACH (Scene*, scene, &bmain->scene) {
-		if (scene->depsgraph == graph) {
-			/* Got the scene! */
-			return scene;
-		}
-	}
-	return NULL;
+	DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
+	return deg_graph->scene;
 }
 
 SceneLayer *DAG_get_scene_layer(Depsgraph *graph)




More information about the Bf-blender-cvs mailing list