This patch allows animation of the collection visibility buttons
(those eyes in the outliner).
Basically completncludes the work starinitiated by @aligorith in on
{rBd1e3ba22a03c}.
In that commit "all necessary data and animation edit(rBd1e3ba22a03c) all necessary data for support changes"to
were implemented. Butanimation of the depsgraph support was incoID were implete.
So, in this patch,mented. I only focused onBut the changes in the depsgraphdepsgraph support was
(and I trusted the original work)incomplete.
##Problematic:So this patch only focused on the depsgraph changes (and trusted the
In the master, a few things get in the way oforiginal work).
##Problematic (what hinders the implementing animation
for collections. These things in the depsgraph are:a):
**1. Deg nodes and relations are not created for invisible collections.**
Every time a collection flag is changed in rna, depsgraph relations are
recreated which "remove" nodes from hidden collections.
Since an invisible collection has no deg nodes, the operand that updatesThis means that
them is never called.if animation tries to unhide a collection, So if the visibility of a collection is animatedthere are no nodes to update
in this case, nothing will changethe scene.
**2. The function that updates any changes to a Collection is not thread-safe and adds a lot of overhead.**
When a collection flag is changed in rnaAs it is not thread-safe, the function is unsuitable as an operand for
the depsgraph node.
Also it adds a lot of overhead. Then a collection flag is changed in rna,
the `BKE_main_collection_sync(bmain)` function is called. This function
deletes lists, Ghash, arrays from all Blender ViewLayers and Collections
and recreates them no matter if an object was deleted or if a Base flag
was just changed.
It is also not thread-safe, which makes the call unsuitable for an
operand of a depsgraph node.
####Proposed Solution:
The solution is similar to what is seen for object visibility animation
(with some changes).
**1. Deg nodes and relations to Collections are always created if the collection is animated.**
This solves the issue of operands not being called if the collection is
invisible.
There are different ways to solve this problem (like callingLike Objects, relations are only created if the datablock is animated.
`DEG_relations_tag_update` in the callback to set the rna value instead
of the update), but I preferred to follow what is seen for Objects,This solves the issue of operands not being called if the collection is
that is, always create the relations.
Unlike Objects, relations are only created if the datablock is animatedhidden.
**2. Implement an update function that updates only the Base flags of a ViewLayer.**
The lightweight `BKE_layer_collection_sync_base_flags` function was implemented
to be called in the operand.
This avoids having to call `BKE_main_collection_sync`.
##To Do
The `BKE_layer_collection_sync_base_flags` function, while working fine
in its current state, does not follow the depsgraph convention as it
directly reads bmain which may not be thread-safe