[Bf-blender-cvs] [c75e74b456f] blender2.8: Depsgraph: Fix wrong detection of invisible objects

Sergey Sharybin noreply at git.blender.org
Fri Aug 24 11:00:00 CEST 2018


Commit: c75e74b456facef2491bc283a87c195cfd91a076
Author: Sergey Sharybin
Date:   Fri Aug 24 10:54:18 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc75e74b456facef2491bc283a87c195cfd91a076

Depsgraph: Fix wrong detection of invisible objects

Was happenign for following cases:

- Deep hierarchy of non-restircted collections, which has grand-grand
  parent restricted.

- Collections which are constructed from invisible object.

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

M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 45c8bb5c93d..979f2197df0 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -143,6 +143,7 @@ DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph)
       view_layer_(NULL),
       view_layer_index_(-1),
       collection_(NULL),
+	  is_parent_collection_visible_(true),
       cow_id_hash_(NULL)
 {
 }
@@ -459,18 +460,19 @@ void DepsgraphNodeBuilder::build_collection(Collection *collection)
 		 */
 		return;
 	}
+	/* Backup state. */
 	Collection *current_state_collection = collection_;
+	const bool is_current_parent_collection_visible =
+	        is_parent_collection_visible_;
+	/* Modify state as we've entered new collection/ */
 	collection_ = collection;
 	const int restrict_flag = (graph_->mode == DAG_EVAL_VIEWPORT)
 	        ? COLLECTION_RESTRICT_VIEW
 	        : COLLECTION_RESTRICT_RENDER;
-	const bool is_parent_collection_restricted =
-	        (current_state_collection == NULL)
-	                ? false
-	                : (current_state_collection->flag & restrict_flag);
 	const bool is_collection_restricted = (collection->flag & restrict_flag);
 	const bool is_collection_visible =
-	        !is_collection_restricted && !is_parent_collection_restricted;
+	        !is_collection_restricted && is_parent_collection_visible_;
+	is_parent_collection_visible_ = is_collection_visible;
 	/* Collection itself. */
 	IDDepsNode *id_node = add_id_node(&collection->id);
 	id_node->is_visible = is_collection_visible;
@@ -483,7 +485,9 @@ void DepsgraphNodeBuilder::build_collection(Collection *collection)
 	LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
 		build_collection(child->collection);
 	}
+	/* Restore state. */
 	collection_ = current_state_collection;
+	is_parent_collection_visible_ = is_current_parent_collection_visible;
 }
 
 void DepsgraphNodeBuilder::build_object(int base_index,
@@ -491,6 +495,9 @@ void DepsgraphNodeBuilder::build_object(int base_index,
                                         eDepsNode_LinkedState_Type linked_state,
                                         bool is_visible)
 {
+	if (string(object->id.name) == "OBGEO-icicles_large_03") {
+		printf(">> %d\n", is_visible);
+	}
 	const bool has_object = built_map_.checkIsBuiltAndTag(object);
 	/* Skip rest of components if the ID node was already there. */
 	if (has_object) {
@@ -569,7 +576,11 @@ void DepsgraphNodeBuilder::build_object(int base_index,
 	}
 	/* Object dupligroup. */
 	if (object->dup_group != NULL) {
+		const bool is_current_parent_collection_visible =
+		        is_parent_collection_visible_;
+		is_parent_collection_visible_ = is_visible;
 		build_collection(object->dup_group);
+		is_parent_collection_visible_ = is_current_parent_collection_visible;
 	}
 }
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index aacb0670a41..e4b253f6d76 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -249,6 +249,11 @@ protected:
 	 * setting the current state.
 	 */
 	Collection *collection_;
+	/* Accumulated flag over the hierarchy opf currently building collections.
+	 * Denotes whether all the hierarchy from parent of collection_ to the
+	 * very root is visible (aka not restricted.).
+	 */
+	bool is_parent_collection_visible_;
 
 	GHash *cow_id_hash_;
 	BuilderMap built_map_;



More information about the Bf-blender-cvs mailing list