LibOverride: Work around reset of system liboverrides on save.

Now that liboverride process on save (the diffing + pruning unused
override operations + reset of non-overridable changes) works better. it
leads to a bad side-effect: all system overrides data indirectly
modified through animation or drivers get reset.

Since in current system e.g. most objects of a rigged asset are system
overrides, but their transform is modified by bones animation, this
leads to entire overrides of assets being reset to their linked state
until next depsgraph evaluation.

While this is the expected and correct behavior in absolute, this is
very bad from a user experience PoV.

This commit address the issue by simply re-running a 'frame change'
despgraph update, to ensure all drivers, animations etc. are properly
re-applied after liboverride diffing cleanup & reset.
This commit is contained in:
Bastien Montagne 2023-07-10 17:54:57 +02:00
parent a05419f18b
commit 457b26aba3
1 changed files with 6 additions and 0 deletions

View File

@ -1905,6 +1905,12 @@ static bool wm_file_write(bContext *C,
/* Enforce full override check/generation on file save. */
BKE_lib_override_library_main_operations_create(bmain, true, nullptr);
/* Process above may reset non-overridable properties that are indirectly edited (e.g. through
* animation or drivers). With system overrides IDs, this can now include transform of most
* objects in an asset. While this is the correct behavior in absolute, it gives (very) bad user
* experience, so just update again depsgraph after it. */
DEG_graph_tag_on_visible_update(CTX_data_depsgraph_pointer(C), true);
/* NOTE: Ideally we would call `WM_redraw_windows` here to remove any open menus.
* But we can crash if saving from a script, see #92704 & #97627.
* Just checking `!G.background && BLI_thread_is_main()` is not sufficient to fix this.