[Bf-blender-cvs] [baa0da3e69a] master: Fix T78071: Drivers reading object visibility not updating automatically

Sybren A. Stüvel noreply at git.blender.org
Thu Jun 25 14:34:07 CEST 2020


Commit: baa0da3e69a1225cd18c075be5563c7d811b5347
Author: Sybren A. Stüvel
Date:   Thu Jun 25 14:30:45 2020 +0200
Branches: master
https://developer.blender.org/rBbaa0da3e69a1225cd18c075be5563c7d811b5347

Fix T78071: Drivers reading object visibility not updating automatically

An object can be targeted by a driver that reads its `hide_viewport` or
`hide_render` property. The existence of such a driver will create a
relation between the 'sync base flags' depsgrpah node, and the datablock
containing the driver. When the object is hidden, however, it has no
base, and thus it had no 'sync base flags' depsgraph node. To support
such a driver, that depsgraph node is now always added, but for hidden
objects it will just be a no-op. If the node is not used by anything, it
will be automatically disconnected and have a negligible effect on
performance.

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

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/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index d84ec9b1363..46dbe97ce23 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -667,8 +667,15 @@ void DepsgraphNodeBuilder::build_object_flags(int base_index,
                                               eDepsNode_LinkedState_Type linked_state)
 {
   if (base_index == -1) {
+    /* An object can be targeted by a driver that reads its `hide_viewport` or `hide_render`
+     * property. For visible objects, these properties are synced from the base flags, so that
+     * driver variable creates a relation from the OBJECT_FROM_LAYER component. However, when the
+     * object is hidden, it has base_index=-1. To support the aforementioned driver, the component
+     * should still exist, even if it's a no-op. See T78071. */
+    add_operation_node(&object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_BASE_FLAGS);
     return;
   }
+
   Scene *scene_cow = get_cow_datablock(scene_);
   Object *object_cow = get_cow_datablock(object);
   const bool is_from_set = (linked_state == DEG_ID_LINKED_VIA_SET);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index e21a83485ad..7b2b048d405 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -757,14 +757,20 @@ void DepsgraphRelationBuilder::build_object_proxy_group(Object *object)
 
 void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object)
 {
-  if (base == nullptr) {
-    return;
-  }
+  /* An object can be targeted by a driver that reads its `hide_viewport` or `hide_render`
+   * property. When the object is hidden, it has no base. To support such a driver, the component
+   * should still have a relation from the view layer, as it should be updated when the object
+   * toggles visiblity. See T78071. */
   OperationKey view_layer_done_key(
       &scene_->id, NodeType::LAYER_COLLECTIONS, OperationCode::VIEW_LAYER_EVAL);
   OperationKey object_flags_key(
       &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_BASE_FLAGS);
   add_relation(view_layer_done_key, object_flags_key, "Base flags flush");
+
+  if (base == nullptr) {
+    return;
+  }
+
   /* Synchronization back to original object. */
   OperationKey synchronize_key(
       &object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL);



More information about the Bf-blender-cvs mailing list