Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-06-25 15:30:45 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-06-25 15:33:56 +0300
commitbaa0da3e69a1225cd18c075be5563c7d811b5347 (patch)
tree7415ab41b349faa6534ebfa8cb72435ca9273438 /source/blender/depsgraph
parent890336849071dd716bc254edbbfa474ed9e61432 (diff)
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.
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc7
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc12
2 files changed, 16 insertions, 3 deletions
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);