Depsgraph iterator: Remove explicit mode
authorDalai Felinto <dfelinto@gmail.com>
Wed, 6 Jun 2018 14:01:51 +0000 (16:01 +0200)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 6 Jun 2018 14:44:51 +0000 (16:44 +0200)
We can get the mode from the depsgraph itself.

source/blender/depsgraph/DEG_depsgraph_query.h
source/blender/depsgraph/intern/depsgraph_query_iter.cc
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_manager.c
source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
source/blender/makesrna/intern/rna_depsgraph.c

index 7a4d9a19335e771beea0ec7ec495b19099987976..1c4e11d119753898b60ff39a4de6403b7b30e03b 100644 (file)
@@ -107,14 +107,8 @@ enum {
        DEG_ITER_OBJECT_FLAG_DUPLI             = (1 << 4),
 };
 
-typedef enum eDepsObjectIteratorMode {
-       DEG_ITER_OBJECT_MODE_VIEWPORT = 0,
-       DEG_ITER_OBJECT_MODE_RENDER   = 1,
-} eDepsObjectIteratorMode;
-
 typedef struct DEGObjectIterData {
        struct Depsgraph *graph;
-       eDepsObjectIteratorMode mode;
        int flag;
 
        struct Scene *scene;
@@ -152,11 +146,10 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
  * Although they are available they have no overrides (collection_properties)
  * and will crash if you try to access it.
  */
-#define DEG_OBJECT_ITER_BEGIN(graph_, instance_, mode_, flag_)                    \
+#define DEG_OBJECT_ITER_BEGIN(graph_, instance_, flag_)                           \
        {                                                                             \
                DEGObjectIterData data_ = {                                               \
                        graph_,                                                               \
-                       mode_,                                                                \
                        flag_                                                                 \
                };                                                                        \
                                                                                   \
@@ -172,8 +165,8 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
 /**
   * Depsgraph objects iterator for draw manager and final render
   */
-#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_, mode_) \
-       DEG_OBJECT_ITER_BEGIN(graph_, instance_, mode_,                       \
+#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(graph_, instance_)        \
+       DEG_OBJECT_ITER_BEGIN(graph_, instance_,                              \
                DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |                        \
                DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |                         \
                DEG_ITER_OBJECT_FLAG_VISIBLE |                                \
index f9bc0da7d2871263608ae68d9bc48fab4b01f20c..97a28038b7b34b32214cc6f431cf20ff82b3644b 100644 (file)
@@ -211,7 +211,9 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
        data->scene = DEG_get_evaluated_scene(depsgraph);
        data->id_node_index = 0;
        data->num_id_nodes = num_id_nodes;
-       data->visibility_check = (data->mode == DEG_ITER_OBJECT_MODE_RENDER)
+       eEvaluationMode eval_mode = DEG_get_mode(depsgraph);
+       /* Viewport rendered mode is DAG_EVAL_PREVIEW but still treated as viewport. */
+       data->visibility_check = (eval_mode == DAG_EVAL_RENDER)
                                 ? OB_VISIBILITY_CHECK_FOR_RENDER
                                 : OB_VISIBILITY_CHECK_FOR_VIEWPORT;
 
index 935a6d362f1ac4c80d5b1ec5b024cffd4b803f37..9f1bfa6ee33efa460540e9c725fa274cbbe9c1cb 100644 (file)
@@ -523,8 +523,6 @@ bool DRW_state_show_text(void);
 bool DRW_state_draw_support(void);
 bool DRW_state_draw_background(void);
 
-enum eDepsObjectIteratorMode DRW_iterator_mode_get(void);
-
 struct DRWTextStore *DRW_state_text_cache_get(void);
 
 /* Avoid too many lookups while drawing */
index 63631dd4a182fd399388553fe49f1e125bead146..a9263abbfaa4dbb4b49241af2b7a2a43d13f7740 100644 (file)
@@ -1295,7 +1295,7 @@ void DRW_draw_render_loop_ex(
                PROFILE_START(stime);
                drw_engines_cache_init();
 
-               DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob, DRW_iterator_mode_get())
+               DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
                {
                        drw_engines_cache_populate(ob);
                }
@@ -1547,7 +1547,7 @@ void DRW_render_object_iter(
 {
        DRW_hair_init();
 
-       DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob, DRW_iterator_mode_get())
+       DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
        {
                DST.ob_state = NULL;
                callback(vedata, ob, engine, depsgraph);
@@ -1692,7 +1692,7 @@ void DRW_draw_select_loop(
                }
                else {
                        DEG_OBJECT_ITER_BEGIN(
-                               depsgraph, ob, DRW_iterator_mode_get(),
+                               depsgraph, ob,
                                DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
                                DEG_ITER_OBJECT_FLAG_VISIBLE |
                                DEG_ITER_OBJECT_FLAG_DUPLI)
@@ -1863,7 +1863,7 @@ void DRW_draw_depth_loop(
        if (cache_is_dirty) {
                drw_engines_cache_init();
 
-               DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob, DRW_iterator_mode_get())
+               DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob)
                {
                        drw_engines_cache_populate(ob);
                }
@@ -1977,15 +1977,6 @@ bool DRW_state_is_opengl_render(void)
        return DST.options.is_image_render && !DST.options.is_scene_render;
 }
 
-/**
- * Gives you the iterator mode to use for depsgraph.
- */
-eDepsObjectIteratorMode DRW_iterator_mode_get(void)
-{
-       return DRW_state_is_scene_render() ? DEG_ITER_OBJECT_MODE_RENDER :
-                                            DEG_ITER_OBJECT_MODE_VIEWPORT;
-}
-
 /**
  * Should text draw in this mode?
  */
index 6cbdca756d5ceb6a76e4894019fb231766cf6781..f41a9b580853aed1b6f6e3c3674c9cd35bb64d5d 100644 (file)
@@ -95,7 +95,7 @@ NodeGroup *BlenderFileLoader::Load()
        int id = 0;
 
        DEG_OBJECT_ITER_BEGIN(
-               depsgraph, ob, DEG_ITER_OBJECT_MODE_RENDER,
+               depsgraph, ob,
                DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
                DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
                DEG_ITER_OBJECT_FLAG_VISIBLE |
index e0c9a9012822f9759f3dc9772e6d457fd4e0da7b..41e69b0d9d75e371d5c131721d452e316f9b9cbe 100644 (file)
@@ -208,7 +208,6 @@ static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, Pointe
        data->flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
                     DEG_ITER_OBJECT_FLAG_VISIBLE |
                     DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
-       data->mode = DEG_ITER_OBJECT_MODE_RENDER;
 
        ((BLI_Iterator *)iter->internal.custom)->valid = true;
        DEG_iterator_objects_begin(iter->internal.custom, data);
@@ -249,7 +248,6 @@ static void rna_Depsgraph_object_instances_begin(CollectionPropertyIterator *ite
                     DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET |
                     DEG_ITER_OBJECT_FLAG_VISIBLE |
                     DEG_ITER_OBJECT_FLAG_DUPLI;
-       data->mode = DEG_ITER_OBJECT_MODE_RENDER;
 
        ((BLI_Iterator *)iter->internal.custom)->valid = true;
        DEG_iterator_objects_begin(iter->internal.custom, data);