diff options
author | Jesse Yurkovich <jesse.y@gmail.com> | 2022-08-04 08:00:52 +0300 |
---|---|---|
committer | Jesse Yurkovich <jesse.y@gmail.com> | 2022-08-04 08:00:52 +0300 |
commit | 72ab6faf5d80a3d26e5b6252e5b6f0041763209c (patch) | |
tree | 81250357e031716b6cac08da1a86da9fcfdc928d /source/blender/editors/space_image | |
parent | 646207c9afd54d8505f5ecb816ca5a90f52af1f6 (diff) |
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
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 4036f859231..78aaf957a87 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3847,15 +3847,16 @@ void IMAGE_OT_clear_render_border(wmOperatorType *ot) static bool do_fill_tile(PointerRNA *ptr, Image *ima, ImageTile *tile) { - float color[4]; - RNA_float_get_array(ptr, "color", color); - int gen_type = RNA_enum_get(ptr, "generated_type"); - int width = RNA_int_get(ptr, "width"); - int height = RNA_int_get(ptr, "height"); + RNA_float_get_array(ptr, "color", tile->gen_color); + tile->gen_type = RNA_enum_get(ptr, "generated_type"); + tile->gen_x = RNA_int_get(ptr, "width"); + tile->gen_y = RNA_int_get(ptr, "height"); bool is_float = RNA_boolean_get(ptr, "float"); - int planes = RNA_boolean_get(ptr, "alpha") ? 32 : 24; - return BKE_image_fill_tile(ima, tile, width, height, color, gen_type, planes, is_float); + tile->gen_flag = is_float ? IMA_GEN_FLOAT : 0; + tile->gen_depth = RNA_boolean_get(ptr, "alpha") ? 32 : 24; + + return BKE_image_fill_tile(ima, tile); } static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout) |