[Bf-blender-cvs] [4e213d42162] blender2.8: Depsgraph iterator: Remove explicit mode

Dalai Felinto noreply at git.blender.org
Wed Jun 6 17:09:49 CEST 2018


Commit: 4e213d42162b8d38435911352e52dbb609e36769
Author: Dalai Felinto
Date:   Wed Jun 6 16:01:51 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4e213d42162b8d38435911352e52dbb609e36769

Depsgraph iterator: Remove explicit mode

We can get the mode from the depsgraph itself.

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

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

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

diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 7a4d9a19335..1c4e11d1197 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -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 |                                \
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index f9bc0da7d28..97a28038b7b 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -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;
 
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 935a6d362f1..9f1bfa6ee33 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -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 */
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 63631dd4a18..a9263abbfaa 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -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?
  */
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
index 6cbdca756d5..f41a9b58085 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp
@@ -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 |
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index e0c9a901282..41e69b0d9d7 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -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);



More information about the Bf-blender-cvs mailing list