forked from bartvdbraak/blender
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.
This commit is contained in:
parent
8903368490
commit
baa0da3e69
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user