From 72ab6faf5d80a3d26e5b6252e5b6f0041763209c Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Wed, 3 Aug 2022 22:00:52 -0700 Subject: Fix T97251: Store generated type information for each UDIM tile Various situations can lead to un-saved UDIM tiles potentially losing their contents. The most notable situation is a save and re-load of a .blend file that has "generated" UDIM tiles that haven't been written to disk yet. Normal "generated" images are reconstructed on demand in these circumstances but UDIM tiles do not retain the information required for reconstruction and empty tiles are presented to the user. This patch stores the generated type information for each tile to solve this particular issue. It also shifts the Image generation info into the 1st tile. The existing DNA fields are deprecated but RNA was modified as to not break API compat. There's two broad changes here that merit special callout: - How to distinguish between a tile that should be reconstructed vs. a tile that should remain empty because loading failed for the UDIMs - How to better handle Image Source changes The first issue is addressed as follows: - Each time a tile is filled with generated content we set a new IMA_GEN_TILE flag - Each time a tile is saved to disk we remove the IMA_GEN_TILE flag - When requesting an ibuf: If the ibuf is null, we check to see if IMA_GEN_TILE is set. If it is set, go ahead and re-create the tile. Otherwise, do nothing. The second set of changes have to do with ensuring that information is carried along as far as possible when the, sometimes destructive, act of changing an Image Source is performed. Behavior should be a bit more natural and expected now; though users will rarely, or should rarely, be modifying this property. The full table describing the behavior is in the differential. Differential Revision: https://developer.blender.org/D14885 --- source/blender/blenloader/intern/versioning_300.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c index 49b14dc84a6..41888e25fb7 100644 --- a/source/blender/blenloader/intern/versioning_300.c +++ b/source/blender/blenloader/intern/versioning_300.c @@ -3318,5 +3318,19 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain) */ { /* Keep this block, even when empty. */ + + /* Image generation information transfered to tiles. */ + if (!DNA_struct_elem_find(fd->filesdna, "ImageTile", "int", "gen_x")) { + for (Image *ima = bmain->images.first; ima; ima = ima->id.next) { + for (ImageTile *tile = ima->tiles.first; tile; tile = tile->next) { + tile->gen_x = ima->gen_x; + tile->gen_y = ima->gen_y; + tile->gen_type = ima->gen_type; + tile->gen_flag = ima->gen_flag; + tile->gen_depth = ima->gen_depth; + copy_v4_v4(tile->gen_color, ima->gen_color); + } + } + } } } -- cgit v1.2.3