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.
This commit is contained in:
2018-04-25 10:13:09 +02:00
parent 1d7bdbd273
commit 9e3e648a08
4 changed files with 65 additions and 17 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();

View File

@@ -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)