[Bf-blender-cvs] [9e3e648a084] blender2.8: Depsgraph: Clarify python API

Sergey Sharybin noreply at git.blender.org
Wed Apr 25 13:04:19 CEST 2018


Commit: 9e3e648a0843b8a45c3d165e710657069bafaf5e
Author: Sergey Sharybin
Date:   Wed Apr 25 10:13:09 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB9e3e648a0843b8a45c3d165e710657069bafaf5e

Depsgraph: Clarify python API

Follow same naming convention as for C:

- Original data is named without any extra prefix/suffix.
- Evaluated data is named with _eval suffix.

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

M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/blender/blender_shader.cpp
M	intern/cycles/blender/blender_sync.cpp
M	source/blender/makesrna/intern/rna_depsgraph.c

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

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index e6aabb5fe36..9d55ece3e0c 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -372,7 +372,7 @@ void BlenderSession::render(BL::Depsgraph& b_depsgraph_)
 	BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_v3d, b_rv3d, scene->camera, width, height);
 
 	/* render each layer */
-	BL::ViewLayer b_view_layer = b_depsgraph.view_layer();
+	BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
 
 	/* We do some special meta attributes when we only have single layer. */
 	const bool is_single_layer = (b_scene.view_layers.length() == 1);
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index ddf18e9f3c7..cc2a6824190 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1229,7 +1229,7 @@ void BlenderSync::sync_materials(BL::Depsgraph& b_depsgraph, bool update_all)
 	    ++b_mat_orig)
 	{
 		/* TODO(sergey): Iterate over evaluated data rather than using mapping. */
-		BL::Material b_mat_(b_depsgraph.evaluated_id_get(*b_mat_orig));
+		BL::Material b_mat_(b_depsgraph.id_eval_get(*b_mat_orig));
 		BL::Material *b_mat = &b_mat_;
 		Shader *shader;
 
@@ -1403,7 +1403,7 @@ void BlenderSync::sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all)
 	    ++b_lamp_orig)
 	{
 		/* TODO(sergey): Iterate over evaluated data rather than using mapping. */
-		BL::Lamp b_lamp_(b_depsgraph.evaluated_id_get(*b_lamp_orig));
+		BL::Lamp b_lamp_(b_depsgraph.id_eval_get(*b_lamp_orig));
 		BL::Lamp *b_lamp = &b_lamp_;
 		Shader *shader;
 
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index bf35f61f07b..94438f613ce 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -195,7 +195,7 @@ void BlenderSync::sync_data(BL::RenderSettings& b_render,
                             int width, int height,
                             void **python_thread_state)
 {
-	BL::ViewLayer b_view_layer = b_depsgraph.view_layer();
+	BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
 
 	sync_view_layer(b_v3d, b_view_layer);
 	sync_integrator();
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index 04e7f64712e..6f8ef99f9c1 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -244,18 +244,39 @@ static PointerRNA rna_Depsgraph_duplis_get(CollectionPropertyIterator *iter)
 	return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphIter, iterator);
 }
 
-static ID *rna_Depsgraph_evaluated_id_get(Depsgraph *depsgraph, ID *id_orig)
+static ID *rna_Depsgraph_id_eval_get(Depsgraph *depsgraph, ID *id_orig)
 {
 	return DEG_get_evaluated_id(depsgraph, id_orig);
 }
 
+static PointerRNA rna_Depsgraph_scene_get(PointerRNA *ptr)
+{
+	Depsgraph *depsgraph = (Depsgraph *)ptr->data;
+	Scene *scene = DEG_get_input_scene(depsgraph);
+	return rna_pointer_inherit_refine(ptr, &RNA_Scene, scene);
+}
+
 static PointerRNA rna_Depsgraph_view_layer_get(PointerRNA *ptr)
 {
 	Depsgraph *depsgraph = (Depsgraph *)ptr->data;
-	ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
+	ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
 	return rna_pointer_inherit_refine(ptr, &RNA_ViewLayer, view_layer);
 }
 
+static PointerRNA rna_Depsgraph_scene_eval_get(PointerRNA *ptr)
+{
+	Depsgraph *depsgraph = (Depsgraph *)ptr->data;
+	Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+	return rna_pointer_inherit_refine(ptr, &RNA_Scene, scene_eval);
+}
+
+static PointerRNA rna_Depsgraph_view_layer_eval_get(PointerRNA *ptr)
+{
+	Depsgraph *depsgraph = (Depsgraph *)ptr->data;
+	ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
+	return rna_pointer_inherit_refine(ptr, &RNA_ViewLayer, view_layer_eval);
+}
+
 #else
 
 static void rna_def_depsgraph_iter(BlenderRNA *brna)
@@ -334,6 +355,8 @@ static void rna_def_depsgraph(BlenderRNA *brna)
 	srna = RNA_def_struct(brna, "Depsgraph", NULL);
 	RNA_def_struct_ui_text(srna, "Dependency Graph", "");
 
+	/* Debug helpers. */
+
 	func = RNA_def_function(srna, "debug_relations_graphviz", "rna_Depsgraph_debug_relations_graphviz");
 	parm = RNA_def_string_file_path(func, "filename", NULL, FILE_MAX, "File Name",
 	                                "File in which to store graphviz debug output");
@@ -356,6 +379,42 @@ static void rna_def_depsgraph(BlenderRNA *brna)
 	RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); /* needed for string return value */
 	RNA_def_function_output(func, parm);
 
+	/* Queries for original datablockls (the ones depsgraph is built for). */
+
+	prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "Scene");
+	RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_get", NULL, NULL, NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for");
+
+	prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "ViewLayer");
+	RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_get", NULL, NULL, NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "View Layer", "Original view layer dependency graph is built for");
+
+	/* Queries for evaluated datablockls (the ones depsgraph is evaluating). */
+
+	func = RNA_def_function(srna, "id_eval_get", "rna_Depsgraph_id_eval_get");
+	parm = RNA_def_pointer(func, "id", "ID", "", "Original ID to get evaluated complementary part for");
+	RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+	parm = RNA_def_pointer(func, "id_eval", "ID", "", "Evaluated ID for the given original one");
+	RNA_def_function_return(func, parm);
+
+	prop = RNA_def_property(srna, "scene_eval", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "Scene");
+	RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_eval_get", NULL, NULL, NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for");
+
+	prop = RNA_def_property(srna, "view_layer_eval", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "ViewLayer");
+	RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_eval_get", NULL, NULL, NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "View Layer", "Original view layer dependency graph is built for");
+
+	/* Iterators. */
+
 	prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_struct_type(prop, "Object");
 	RNA_def_property_collection_funcs(prop,
@@ -365,12 +424,6 @@ static void rna_def_depsgraph(BlenderRNA *brna)
 	                                  "rna_Depsgraph_objects_get",
 	                                  NULL, NULL, NULL, NULL);
 
-	func = RNA_def_function(srna, "evaluated_id_get", "rna_Depsgraph_evaluated_id_get");
-	parm = RNA_def_pointer(func, "id", "ID", "", "Original ID to get evaluated complementary part for");
-	RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-	parm = RNA_def_pointer(func, "evaluated_id", "ID", "", "Evaluated ID for the given original one");
-	RNA_def_function_return(func, parm);
-
 	/* TODO(sergey): Find a better name. */
 	prop = RNA_def_property(srna, "duplis", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_struct_type(prop, "DepsgraphIter");
@@ -380,11 +433,6 @@ static void rna_def_depsgraph(BlenderRNA *brna)
 	                                  "rna_Depsgraph_duplis_end",
 	                                  "rna_Depsgraph_duplis_get",
 	                                  NULL, NULL, NULL, NULL);
-
-	prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE);
-	RNA_def_property_struct_type(prop, "ViewLayer");
-	RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_get", NULL, NULL, NULL);
-	RNA_def_property_ui_text(prop, "Scene layer", "");
 }
 
 void RNA_def_depsgraph(BlenderRNA *brna)



More information about the Bf-blender-cvs mailing list