[Bf-blender-cvs] [9ad2c0b6154] blender2.8: Depsgraph and collection enable/visibility

Dalai Felinto noreply at git.blender.org
Thu Sep 21 14:46:00 CEST 2017


Commit: 9ad2c0b6154b8e11521e9ee0422a79d5e0b9a2e1
Author: Dalai Felinto
Date:   Thu Sep 21 12:55:14 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB9ad2c0b6154b8e11521e9ee0422a79d5e0b9a2e1

Depsgraph and collection enable/visibility

Iterate over invisible objects too, so lamps can still lit the scene.
Also, now you can use a collection to set an object to invisible, not
only to visible.

For example:
Scene > Master collection > bedroom > furniture
Scene > View Layer > bedroom    (visible)
                   > furniture  (invisible)

The View Layer has two linked collections, bedroom and furniture.
This setup will make the furniture collection invisible.

Note: Unlike what was suggested on D2849, this does not make collection
visibility influence camera visibility. I will keep this as a separate
patch.

Reviewers: sergey

Subscribers: sergey, brecht, fclem

Differential Revision: https://developer.blender.org/D2849

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

M	intern/cycles/blender/blender_object.cpp
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/layer.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/depsgraph/intern/depsgraph_query.cc
M	source/blender/draw/engines/eevee/eevee_engine.c
M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/modes/object_mode.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blender/makesrna/intern/rna_object_api.c

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

diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 991b834dcfa..635f1d2eb46 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -519,6 +519,10 @@ void BlenderSync::sync_objects(float motion_time)
 	    ++b_dupli_iter)
 	{
 		BL::Object b_ob = b_dupli_iter->object();
+		if(!b_ob.is_visible()) {
+			continue;
+		}
+
 		progress.set_sync_status("Synchronizing object", b_ob.name());
 
 		/* load per-object culling data */
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 35cde742ff0..ce6a95c682b 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -83,6 +83,7 @@ bool BKE_object_exists_check(struct Object *obtest);
 bool BKE_object_is_in_editmode(struct Object *ob);
 bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
 bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
+bool BKE_object_is_visible(struct Object *ob);
 
 void BKE_object_init(struct Object *ob);
 struct Object *BKE_object_add_only_object(
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 5d0cb6ae430..126a2b7bb6c 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1860,6 +1860,9 @@ void BKE_layer_eval_layer_collection(const struct EvaluationContext *UNUSED(eval
 			IDP_MergeGroup(base->collection_properties, layer_collection->properties_evaluated, true);
 			base->flag |= BASE_VISIBLED;
 		}
+		else {
+			base->flag &= ~BASE_VISIBLED;
+		}
 
 		if (is_selectable) {
 			base->flag |= BASE_SELECTABLED;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 9f48d8f6b11..cfb6db35810 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -562,6 +562,15 @@ bool BKE_object_is_in_wpaint_select_vert(Object *ob)
 	return false;
 }
 
+/**
+ * Return if the object is visible, as evaluated by depsgraph
+ * Keep in sync with rna_object.c (object.is_visible).
+ */
+bool BKE_object_is_visible(Object *ob)
+{
+	return (ob->base_flag & BASE_VISIBLED) != 0;
+}
+
 bool BKE_object_exists_check(Object *obtest)
 {
 	Object *ob;
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 7d0ac47e6fd..0d06cc48b88 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -211,33 +211,30 @@ void DEG_objects_iterator_next(BLI_Iterator *iter)
 	}
 
 	base = data->base->next;
-	while (base != NULL) {
-		if ((base->flag & BASE_VISIBLED) != 0) {
-			// Object *ob = DEG_get_evaluated_object(data->graph, base->object);
-			Object *ob = base->object;
-			iter->current = ob;
-			data->base = base;
-
-			BLI_assert(DEG::deg_validate_copy_on_write_datablock(&ob->id));
-
-			/* Make sure we have the base collection settings is already populated.
-			 * This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
-			 * Which usually means a missing call to DEG_id_tag_update(). */
-			BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
-
-			/* Flushing depsgraph data. */
-			deg_flush_base_flags_and_settings(ob,
-			                                  base,
-			                                  data->base_flag);
-
-			if ((data->flag & DEG_OBJECT_ITER_FLAG_DUPLI) && (ob->transflag & OB_DUPLI)) {
-				data->dupli_parent = ob;
-				data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, ob);
-				data->dupli_object_next = (DupliObject *)data->dupli_list->first;
-			}
-			return;
+	if (base != NULL) {
+		// Object *ob = DEG_get_evaluated_object(data->graph, base->object);
+		Object *ob = base->object;
+		iter->current = ob;
+		data->base = base;
+
+		BLI_assert(DEG::deg_validate_copy_on_write_datablock(&ob->id));
+
+		/* Make sure we have the base collection settings is already populated.
+		 * This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
+		 * Which usually means a missing call to DEG_id_tag_update(). */
+		BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
+
+		/* Flushing depsgraph data. */
+		deg_flush_base_flags_and_settings(ob,
+										  base,
+										  data->base_flag);
+
+		if ((data->flag & DEG_OBJECT_ITER_FLAG_DUPLI) && (ob->transflag & OB_DUPLI)) {
+			data->dupli_parent = ob;
+			data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, ob);
+			data->dupli_object_next = (DupliObject *)data->dupli_list->first;
 		}
-		base = base->next;
+		return;
 	}
 
 	/* Look for an object in the next set. */
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index e8821f23633..f27b5236d71 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -29,6 +29,8 @@
 #include "BLI_dynstr.h"
 #include "BLI_rand.h"
 
+#include "BKE_object.h"
+
 #include "GPU_material.h"
 #include "GPU_glew.h"
 
@@ -93,6 +95,10 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
 	}
 
 	if (ELEM(ob->type, OB_MESH)) {
+		if (!BKE_object_is_visible(ob)) {
+			return;
+		}
+
 		EEVEE_materials_cache_populate(vedata, sldata, ob);
 
 		const bool cast_shadow = true;
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 96db3164fe1..a37dc091aa8 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -590,7 +590,10 @@ static void EEVEE_planar_reflections_updates(EEVEE_SceneLayerData *sldata, EEVEE
 		eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale;
 
 		/* Debug Display */
-		if (DRW_state_draw_support() && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
+		if (BKE_object_is_visible(ob) &&
+		    DRW_state_draw_support() &&
+		    (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+		{
 			DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_planar_display_sh, psl->probe_display);
 
 			DRW_shgroup_uniform_int(grp, "probeIdx", &ped->probe_id, 1);
@@ -643,8 +646,12 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
 		invert_m4(eprobe->parallaxmat);
 
 		/* Debug Display */
-		if (DRW_state_draw_support() && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
-			DRW_shgroup_call_dynamic_add(stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &probe->data_draw_size);
+		if (BKE_object_is_visible(ob) &&
+			DRW_state_draw_support() &&
+		    (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+		{
+			DRW_shgroup_call_dynamic_add(
+			            stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &probe->data_draw_size);
 		}
 	}
 
@@ -701,7 +708,10 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
 		copy_v3_v3_int(egrid->resolution, &probe->grid_resolution_x);
 
 		/* Debug Display */
-		if (DRW_state_draw_support() && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
+		if (BKE_object_is_visible(ob) &&
+		    DRW_state_draw_support() &&
+		    (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+		{
 			struct Gwn_Batch *geom = DRW_cache_sphere_get();
 			DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.probe_grid_display_sh, psl->probe_display, geom);
 			DRW_shgroup_set_instance_count(grp, ped->num_cell);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index bd143e33d09..b20c9fe013b 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2164,6 +2164,10 @@ bool DRW_object_is_renderable(Object *ob)
 	Scene *scene = DST.draw_ctx.scene;
 	Object *obedit = scene->obedit;
 
+	if (!BKE_object_is_visible(ob)) {
+		return false;
+	}
+
 	if (ob->type == OB_MESH) {
 		if (ob == obedit) {
 			IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_EDIT, "");
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 933f8a60b9f..22571808cbc 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -43,6 +43,7 @@
 #include "BKE_camera.h"
 #include "BKE_curve.h"
 #include "BKE_global.h"
+#include "BKE_object.h"
 #include "BKE_particle.h"
 #include "BKE_image.h"
 #include "BKE_texture.h"
@@ -1562,7 +1563,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
 
 static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
 {
-	if (ob->parent && ((ob->parent->base_flag & BASE_VISIBLED) != 0)) {
+	if (ob->parent && BKE_object_is_visible(ob->parent)) {
 		DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->obmat[3]);
 		DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->parent->obmat[3]);
 	}
@@ -1677,6 +1678,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
 	View3D *v3d = draw_ctx->v3d;
 	int theme_id = TH_UNDEFINED;
 
+	if (!BKE_object_is_visible(ob)) {
+		return;
+	}
+
 	//CollectionEngineSettings *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
 
 	//bool do_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_wire");
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 2fce8783aa2..4df7f6762bc 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -9217,7 +9217,7 @@ afterdraw:
 
 		/* help lines and so */
 		if (ob != scene->obedit && ob->parent) {
-			if ((ob->parent->base_flag & BASE_VISIBLED) != 0) {
+			if (BKE_object_is_visible(ob->parent)) {
 				setlinestyle(3);
 				immBegin(GWN_PRIM_LINES, 2);
 				immVertex3fv(pos, ob->obmat[3]);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 427ef5c307f..e57333fb8a7 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list