[Bf-blender-cvs] [77879ac038e] blender2.8: Fix T55376: instanced collection render visibility ignored.

Brecht Van Lommel noreply at git.blender.org
Tue Jun 12 22:36:51 CEST 2018


Commit: 77879ac038e3576eeeeb651ce78706cb95399098
Author: Brecht Van Lommel
Date:   Fri Jun 8 19:26:46 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB77879ac038e3576eeeeb651ce78706cb95399098

Fix T55376: instanced collection render visibility ignored.

For physics simulation it's still fuzzy though, but this needs bigger
design for how it works with view layers and visibility.

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

M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenkernel/intern/dynamicpaint.c
M	source/blender/blenkernel/intern/effect.c
M	source/blender/blenkernel/intern/object_dupli.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/blenkernel/intern/rigidbody.c
M	source/blender/blenkernel/intern/softbody.c
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc

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

diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index fc5b19ccb4f..7dce3b2c703 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -90,14 +90,13 @@ void BKE_collections_child_remove_nulls(struct Main *bmain, struct Collection *o
 bool BKE_collection_is_in_scene(struct Collection *collection);
 void BKE_collections_after_lib_link(struct Main *bmain);
 bool BKE_collection_object_cyclic_check(struct Main *bmain, struct Object *object, struct Collection *collection);
-bool BKE_collection_is_animated(struct Collection *collection, struct Object *parent);
 
 /* Object list cache. */
 
 struct ListBase BKE_collection_object_cache_get(struct Collection *collection);
 void BKE_collection_object_cache_free(struct Collection *collection);
 
-struct Base *BKE_collection_or_layer_objects(struct Depsgraph *depsgraph,
+struct Base *BKE_collection_or_layer_objects(const struct Depsgraph *depsgraph,
                                              const struct Scene *scene,
                                              const struct ViewLayer *view_layer,
                                              struct Collection *collection);
@@ -139,13 +138,21 @@ void BKE_scene_objects_callback(struct Scene *scene, BKE_scene_objects_Cb callba
 
 /* Iteratorion over objects in collection. */
 
-#define FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(_collection, _base)               \
-	for (Base *_base = (Base*)BKE_collection_object_cache_get(_collection).first; \
-	     _base;                                                                   \
-	     _base = _base->next)                                                     \
-	{
-
-#define FOREACH_COLLECTION_BASE_RECURSIVE_END                                     \
+#define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(_collection, _object, _mode) \
+    {                                                                                  \
+		int _base_flag = (_mode == DAG_EVAL_VIEWPORT) ?                                \
+			BASE_VISIBLE_VIEWPORT : BASE_VISIBLE_RENDER;                               \
+		int _base_id = 0;                                                              \
+		for (Base *_base = (Base*)BKE_collection_object_cache_get(_collection).first;  \
+			 _base;                                                                    \
+			 _base = _base->next, _base_id++)                                          \
+		{                                                                              \
+			if (_base->flag & _base_flag) {                                            \
+				Object *_object = _base->object;                                       \
+
+#define FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END                               \
+			}                                                                         \
+		}                                                                             \
 	}
 
 #define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)           \
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index ab0ec8b0491..3f30082576c 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -297,20 +297,6 @@ void BKE_collection_new_name_get(Collection *collection_parent, char *rname)
 	MEM_freeN(name);
 }
 
-/************************* Dependencies ****************************/
-
-bool BKE_collection_is_animated(Collection *collection, Object *UNUSED(parent))
-{
-	FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(collection, object)
-	{
-		if (object->proxy) {
-			return true;
-		}
-	}
-	FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
-	return false;
-}
-
 /* **************** Object List Cache *******************/
 
 static void collection_object_cache_fill(ListBase *lb, Collection *collection, int parent_restrict)
@@ -325,13 +311,8 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i
 			base->object = cob->ob;
 
 			if ((child_restrict & COLLECTION_RESTRICT_VIEW) == 0) {
-				base->flag |= BASE_VISIBLED | BASE_VISIBLE_VIEWPORT;
-
-				if ((child_restrict & COLLECTION_RESTRICT_SELECT) == 0) {
-					base->flag |= BASE_SELECTABLED;
-				}
+				base->flag |= BASE_VISIBLE_VIEWPORT;
 			}
-
 			if ((child_restrict & COLLECTION_RESTRICT_RENDER) == 0) {
 				base->flag |= BASE_VISIBLE_RENDER;
 			}
@@ -377,7 +358,7 @@ void BKE_collection_object_cache_free(Collection *collection)
 	collection_object_cache_free(collection);
 }
 
-Base *BKE_collection_or_layer_objects(Depsgraph *depsgraph,
+Base *BKE_collection_or_layer_objects(const Depsgraph *depsgraph,
                                       const Scene *scene,
                                       const ViewLayer *view_layer,
                                       Collection *collection)
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 0b2c65a7b8d..ed2566c9bb5 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -490,9 +490,9 @@ static void scene_setSubframe(Scene *scene, float subframe)
 	scene->r.subframe = subframe;
 }
 
-static int surface_getBrushFlags(DynamicPaintSurface *surface, const ViewLayer *view_layer)
+static int surface_getBrushFlags(DynamicPaintSurface *surface, const Depsgraph *depsgraph)
 {
-	Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, surface->brush_group);
+	Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, surface->brush_group);
 	Object *brushObj = NULL;
 	ModifierData *md = NULL;
 
@@ -5758,7 +5758,7 @@ static void dynamic_paint_generate_bake_data_cb(
 	}
 }
 
-static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const ViewLayer *view_layer, Object *ob)
+static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Depsgraph *depsgraph, Object *ob)
 {
 	PaintSurfaceData *sData = surface->data;
 	PaintBakeData *bData = sData->bData;
@@ -5766,7 +5766,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, const Vie
 	int index;
 	bool new_bdata = false;
 	const bool do_velocity_data = ((surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) ||
-	                               (surface_getBrushFlags(surface, view_layer) & BRUSH_USES_VELOCITY));
+	                               (surface_getBrushFlags(surface, depsgraph) & BRUSH_USES_VELOCITY));
 	const bool do_accel_data = (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) != 0;
 
 	int canvasNumOfVerts = dm->getNumVerts(dm);
@@ -5912,8 +5912,7 @@ static int dynamicPaint_doStep(
 	{
 		Object *brushObj = NULL;
 		ModifierData *md = NULL;
-		ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
-		Base *base = BKE_collection_or_layer_objects(NULL, NULL, view_layer, surface->brush_group);
+		Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, surface->brush_group);
 
 		/* backup current scene frame */
 		int scene_frame = scene->r.cfra;
@@ -6051,8 +6050,7 @@ int dynamicPaint_calculateFrame(
 		dynamicPaint_applySurfaceDisplace(surface, surface->canvas->dm);
 
 	/* update bake data */
-	ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
-	dynamicPaint_generateBakeData(surface, view_layer, cObject);
+	dynamicPaint_generateBakeData(surface, depsgraph, cObject);
 
 	/* don't do substeps for first frame */
 	if (surface->substeps && (frame != surface->start_frame)) {
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index bdf6e84a3b1..3bf58b8886a 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -219,10 +219,6 @@ ListBase *pdInitEffectors(
 	ListBase *effectors = NULL;
 
 	for (; base; base = base->next) {
-		if ((base->flag & BASE_VISIBLED) == 0) {
-			continue;
-		}
-
 		if (base->object->pd && base->object->pd->forcefield) {
 			add_object_to_effectors(&effectors, depsgraph, scene, weights, base->object, ob_src, for_simulation);
 		}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 57cdfdebcd3..e48a04c5726 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -233,13 +233,12 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild
 	Object *parent = ctx->object;
 
 	if (ctx->collection) {
-		int collectionid = 0;
-		FOREACH_COLLECTION_BASE_RECURSIVE_BEGIN(ctx->collection, base)
+		eEvaluationMode mode = DEG_get_mode(ctx->depsgraph);
+		FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(ctx->collection, ob, mode)
 		{
-			Object *ob = base->object;
-			if ((base->flag & BASE_VISIBLED) && ob != ctx->obedit && is_child(ob, parent)) {
+			if ((ob != ctx->obedit) && is_child(ob, parent)) {
 				DupliContext pctx;
-				copy_dupli_context(&pctx, ctx, ctx->object, NULL, collectionid);
+				copy_dupli_context(&pctx, ctx, ctx->object, NULL, _base_id);
 
 				/* mballs have a different dupli handling */
 				if (ob->type != OB_MBALL) {
@@ -247,9 +246,8 @@ static void make_child_duplis(const DupliContext *ctx, void *userdata, MakeChild
 				}
 				make_child_duplis_cb(&pctx, userdata, ob);
 			}
-			collectionid++;
 		}
-		FOREACH_COLLECTION_BASE_RECURSIVE_END
+		FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END;
 	}
 	else {
 		int baseid = 0;
@@ -278,9 +276,7 @@ static void make_duplis_collection(const DupliContext *ctx)
 {
 	Object *ob = ctx->object;
 	Collection *collection;
-	Base *base;
 	float collection_mat[4][4];
-	int id;
 
 	if (ob->dup_group == NULL) return;
 	collection = ob->dup_group;
@@ -291,20 +287,22 @@ static void make_duplis_collection(const DupliContext *ctx)
 	mul_m4_m4m4(collection_mat, ob->obmat, collection_mat);
 	/* don't access 'ob->obmat' from now on. */
 
-	const ListBase dup_collection_objects = BKE_collection_object_cache_get(collection);
-	for (base = dup_collection_objects.first, id = 0; base; base = base->next, id++) {
-		if (base->object != ob && (base->flag & BASE_VISIBLED)) {
+	eEvaluationMode mode = DEG_get_mo

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list