[Bf-blender-cvs] [f6b66e76e1] clay-engine: Use new temporary depsgraph

Dalai Felinto noreply at git.blender.org
Tue Jan 31 15:22:04 CET 2017


Commit: f6b66e76e15d4c06030dd8a4e531888e12033e3e
Author: Dalai Felinto
Date:   Tue Jan 31 15:21:40 2017 +0100
Branches: clay-engine
https://developer.blender.org/rBf6b66e76e15d4c06030dd8a4e531888e12033e3e

Use new temporary depsgraph

The idea is to use only Object, never Base

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

M	source/blender/blenkernel/BKE_layer.h
M	source/blender/draw/engines/clay/clay.c
M	source/blender/draw/intern/draw_mode_pass.c
M	source/blender/draw/intern/draw_mode_pass.h

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

diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 6373593f19..e74cfbe9a1 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -144,15 +144,6 @@ void BKE_visible_bases_Iterator_end(Iterator *iter);
     }                                                                         \
 }
 
-#define FOREACH_BASE(sl, _object_base)                                        \
-{                                                                             \
-	for (base = sl->object_bases.first; base; base = base->next) {            \
-	    _object_base = base;
-
-#define FOREACH_BASE_END                                                      \
-    }                                                                         \
-}
-
 #define FOREACH_OBJECT_FLAG(scene, sl, flag, _ob)                             \
 {                                                                             \
 	IteratorBeginCb func_begin;                                               \
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index dabb500936..844cd5b4ec 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -529,7 +529,6 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
 {
 	SceneLayer *sl = CTX_data_scene_layer(C);
 	DRWShadingGroup *default_shgrp, *depthbatch;
-	ObjectBase *base;
 
 	/* Depth Pass */
 	{
@@ -558,11 +557,14 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
 	}
 
 	/* TODO Create hash table of batch based on material id*/
-	FOREACH_BASE(sl, base)
+	Object *ob;
+	DEG_OBJECT_ITER(sl, ob)
 	{
-		struct Batch *geom;
-		Object *ob = base->object;
+		if ((ob->base_flag & BASE_VISIBLED) == 0) {
+			continue;
+		}
 
+		struct Batch *geom;
 		switch (ob->type) {
 			case OB_MESH:
 				geom = DRW_cache_surface_get(ob);
@@ -584,14 +586,14 @@ static void CLAY_create_cache(CLAY_PassList *passes, const struct bContext *C)
 			case OB_CAMERA:
 			case OB_EMPTY:
 			default:
-				DRW_shgroup_non_meshes(passes->non_meshes_pass, base);
+			    DRW_shgroup_non_meshes(passes->non_meshes_pass, ob);
 				break;
 		}
 
-		DRW_shgroup_object_center(passes->ob_center_pass, base);
-		DRW_shgroup_relationship_lines(passes->non_meshes_pass, base);
+		DRW_shgroup_object_center(passes->ob_center_pass, ob);
+		DRW_shgroup_relationship_lines(passes->non_meshes_pass, ob);
 	}
-	FOREACH_BASE_END
+	DEG_OBJECT_ITER_END
 }
 
 static void CLAY_view_draw(RenderEngine *UNUSED(engine), const struct bContext *context)
diff --git a/source/blender/draw/intern/draw_mode_pass.c b/source/blender/draw/intern/draw_mode_pass.c
index 0cb6929de2..2156a860c5 100644
--- a/source/blender/draw/intern/draw_mode_pass.c
+++ b/source/blender/draw/intern/draw_mode_pass.c
@@ -284,9 +284,8 @@ void DRW_shgroup_wire_outline(DRWPass *wire_outline, Object *ob,
 /* ***************************** NON MESHES ********************** */
 
 /* TODO FINISH */
-static int draw_object_wire_theme(ObjectBase *base)
+static int draw_object_wire_theme(Object *ob)
 {
-	Object *ob = base->object;
 	const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
 	/* confusing logic here, there are 2 methods of setting the color
 	 * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
@@ -295,15 +294,15 @@ static int draw_object_wire_theme(ObjectBase *base)
 	int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE;
 
 	if (//(scene->obedit == NULL) &&
-	    (G.moving & G_TRANSFORM_OBJ) &&
-	    (base->flag & BASE_SELECTED))
+	    ((G.moving & G_TRANSFORM_OBJ) != 0) &&
+	    ((ob->base_flag & BASE_SELECTED) != 0))
 	{
 		theme_id = TH_TRANSFORM;
 	}
 	else {
 		/* Sets the 'theme_id' or fallback to wire */
 		if ((ob->flag & OB_FROMGROUP) != 0) {
-			if (base->flag & BASE_SELECTED) {
+			if ((ob->base_flag & BASE_SELECTED) != 0) {
 				/* uses darker active color for non-active + selected */
 				theme_id = TH_GROUP_ACTIVE;
 
@@ -316,7 +315,7 @@ static int draw_object_wire_theme(ObjectBase *base)
 			}
 		}
 		else {
-			if (base->flag & BASE_SELECTED) {
+			if ((ob->base_flag & BASE_SELECTED) != 0) {
 				theme_id = //scene->basact == base ? TH_ACTIVE :
 				TH_SELECT;
 			}
@@ -333,12 +332,11 @@ static int draw_object_wire_theme(ObjectBase *base)
 	return theme_id;
 }
 
-void DRW_shgroup_non_meshes(DRWPass *UNUSED(non_meshes), ObjectBase *base)
+void DRW_shgroup_non_meshes(DRWPass *UNUSED(non_meshes), Object *ob)
 {
 	struct Batch *geom;
 	DRWShadingGroup *grp;
-	Object *ob = base->object;
-	int theme_id = draw_object_wire_theme(base);
+	int theme_id = draw_object_wire_theme(ob);
 
 	switch (ob->type) {
 		case OB_LAMP:
@@ -364,9 +362,8 @@ void DRW_shgroup_non_meshes(DRWPass *UNUSED(non_meshes), ObjectBase *base)
 	}
 }
 
-void DRW_shgroup_relationship_lines(DRWPass *UNUSED(non_meshes), ObjectBase *base)
+void DRW_shgroup_relationship_lines(DRWPass *UNUSED(non_meshes), Object *ob)
 {
-	Object *ob = base->object;
 	if (ob->parent) {
 		struct Batch *geom = DRW_cache_single_vert_get();
 		DRW_shgroup_call_add(relationship_lines, geom, ob->obmat);
@@ -376,13 +373,14 @@ void DRW_shgroup_relationship_lines(DRWPass *UNUSED(non_meshes), ObjectBase *bas
 
 /* ***************************** COMMON **************************** */
 
-void DRW_shgroup_object_center(DRWPass *UNUSED(ob_center), ObjectBase *base)
+void DRW_shgroup_object_center(DRWPass *UNUSED(ob_center), Object *ob)
 {
-	Object *ob = base->object;
 	struct Batch *geom = DRW_cache_single_vert_get();
 
-	if (base->flag & BASE_SELECTED)
+	if ((ob->base_flag & BASE_SELECTED) != 0) {
 		DRW_shgroup_call_add(center_selected, geom, ob->obmat);
-	else
+	}
+	else {
 		DRW_shgroup_call_add(center_deselected, geom, ob->obmat);
-}
\ No newline at end of file
+	}
+}
diff --git a/source/blender/draw/intern/draw_mode_pass.h b/source/blender/draw/intern/draw_mode_pass.h
index 3468fdaa6f..d11213ec8a 100644
--- a/source/blender/draw/intern/draw_mode_pass.h
+++ b/source/blender/draw/intern/draw_mode_pass.h
@@ -30,15 +30,16 @@
 
 struct DRWPass;
 struct Batch;
+struct Object;
 
 void DRW_pass_setup_common(struct DRWPass **wire_overlay, struct DRWPass **wire_outline, struct DRWPass **non_meshes, struct DRWPass **ob_center);
 
-void DRW_shgroup_wire_overlay(struct DRWPass *wire_overlay, Object *ob);
+void DRW_shgroup_wire_overlay(struct DRWPass *wire_overlay, struct Object *ob);
 void DRW_shgroup_wire_outline(
-        struct DRWPass *wire_outline, Object *ob, const bool do_front, const bool do_back, const bool do_outline);
+        struct DRWPass *wire_outline, struct Object *ob, const bool do_front, const bool do_back, const bool do_outline);
 
-void DRW_shgroup_non_meshes(struct DRWPass *non_meshes, ObjectBase *base);
-void DRW_shgroup_relationship_lines(struct DRWPass *non_meshes, ObjectBase *base);
-void DRW_shgroup_object_center(struct DRWPass *ob_center, ObjectBase *base);
+void DRW_shgroup_non_meshes(struct DRWPass *non_meshes, struct Object *ob);
+void DRW_shgroup_relationship_lines(struct DRWPass *non_meshes, struct Object *ob);
+void DRW_shgroup_object_center(struct DRWPass *ob_center, struct Object *ob);
 
 #endif /* __DRAW_MODE_PASS_H__ */
\ No newline at end of file




More information about the Bf-blender-cvs mailing list