Depsgraph: Expose (evaluation) mode in rna
authorDalai Felinto <dfelinto@gmail.com>
Wed, 6 Jun 2018 14:38:10 +0000 (16:38 +0200)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 6 Jun 2018 14:44:51 +0000 (16:44 +0200)
source/blender/makesrna/intern/rna_depsgraph.c

index 41e69b0d9d75e371d5c131721d452e316f9b9cbe..f904d4c06b1b41ea599a2782e21859e5f82be3a4 100644 (file)
@@ -128,6 +128,14 @@ static int rna_DepsgraphObjectInstance_is_instance_get(PointerRNA *ptr)
        return (deg_iter->dupli_object_current != NULL);
 }
 
+/* ******************** Sorted  ***************** */
+
+static int rna_Depsgraph_mode_get(PointerRNA *ptr)
+{
+       Depsgraph *depsgraph = ptr->data;
+       return DEG_get_mode(depsgraph);
+}
+
 /* ******************** Updates ***************** */
 
 static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr)
@@ -464,9 +472,20 @@ static void rna_def_depsgraph(BlenderRNA *brna)
        PropertyRNA *parm;
        PropertyRNA *prop;
 
+       static EnumPropertyItem enum_depsgraph_mode_items[] = {
+               {DAG_EVAL_VIEWPORT, "VIEWPORT", 0, "Viewport", "Viewport non-rendered mode"},
+               {DAG_EVAL_PREVIEW, "PREVIEW", 0, "Preview", "Viewport rendered draw mode"},
+               {DAG_EVAL_RENDER, "RENDER", 0, "Render", "Render"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        srna = RNA_def_struct(brna, "Depsgraph", NULL);
        RNA_def_struct_ui_text(srna, "Dependency Graph", "");
 
+       prop = RNA_def_enum(srna, "mode", enum_depsgraph_mode_items, 0, "Mode", "Evaluation mode");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_enum_funcs(prop, "rna_Depsgraph_mode_get", NULL, NULL);
+
        /* Debug helpers. */
 
        func = RNA_def_function(srna, "debug_relations_graphviz", "rna_Depsgraph_debug_relations_graphviz");