BKE: Rework ID swap code to properly handle embedded ID pointers. #107044

Merged
Bastien Montagne merged 1 commits from mont29/blender:F-swap-embedded-id into main 2023-04-18 11:09:47 +02:00

1 Commits

Author SHA1 Message Date
Bastien Montagne e615947d6a BKE: Rework ID swap code to properly handle embedded ID pointers.
While embedded IDs are usually considered as private local data of their
owner ID, some areas of code, like the depsgraph, can consider them as
regular IDs in some aspects.

So when swapping IDs, also properly 'counter-swap' their potential
embedded IDs, such that the pointers to the embedded IDs remain as before
swapping, even though the data of the embedded IDs is swapped.

The main target of this change is memfile undo code. There, newly read
IDs are swapped with their oldder version, so that the old address
contains the new data. This allows to avoid rebuilding some of the
depsgraph. Doing the same thing for embedded IDs should reduce even
further the needs for depsgrah rebuilds on undo steps.

This commit also gives more control over the remapping of 'self' ID
pointers inside themselves.
2023-04-18 11:05:49 +02:00