LibOverride: Restore local references to virtual linked liboverrides on resync. #107144

Merged
Bastien Montagne merged 3 commits from mont29/blender:F-liboverride-resync-replace-missing-ids into main 2023-05-08 18:22:39 +02:00

3 Commits

Author SHA1 Message Date
Bastien Montagne 5637384156 Fix after merging main. 2023-05-08 17:24:36 +02:00
Bastien Montagne 853fcad47c Merge branch 'main' into F-liboverride-resync-replace-missing-ids 2023-05-08 17:09:24 +02:00
Bastien Montagne 5e0c77594a LibOverride: Restore local references to virtual linked liboverrides on resync.
When resyncing linked liboverride data, new IDs may be created that do
not exist in actual library file (since the lib file has not been resynced).

If such 'virtual linked liboverrides' data-blocks are used locally (e.g.
by adding such object to a local collection), on next file read they will be
detected as missing.

Now resync code will list such missing linked IDs that were
liboverrides, and try to re-use them when matching (by root name and
library) with newly generated virtual liboverrides.

The process may not be 100% perfect, especially a perfect one-to-one
remapping cannot be ensured if source data keep being changed over and
over (because of the order in which virtual linked liboverrides
generated by resync may change over time). However, in practice this
should fix the vast majority of issues, especially if sane naming
practices are used on IDs.

---------------

For the record, an attempt was made to write liboverride data together
with the placeholders for linked IDs in .blendfile. In theory, this
should ensure a perfect and fully valid re-usage of such IDs.

However, for this to work, not opnly the liboverride data of linked IDs need
to be written on disk, but also all ID references in this data has to be
considered as directly linked, to ensure that such liboverride data can
be re-read properly.

Otherwise, these placeholders would get a liboverride data with NULL ID
pointers, which is useless.

Such change feels way to intrusive for the very limited benefit, so for
now would consider current solution as the best option.
2023-05-01 11:36:17 +02:00