diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-05 03:25:31 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-08-12 10:24:48 +0300 |
commit | 220470be1515d90ae2c3157648bd9da311925427 (patch) | |
tree | 6d83066815044a08792ffe64f65c5ccb55ef7b00 | |
parent | 02c3428e0c7544cc3631a88757226e8956367f1a (diff) |
Fix T78529: Blend file corrupted during save caused by high Cubemap Size
This just avoid the corruption. A better fix still need to be finished.
See P1564
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 657d776e57c..1b0c2cbac15 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6501,7 +6501,7 @@ static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lcte if (lctex->data) { lctex->data = newdataadr(fd, lctex->data); - if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { + if (lctex->data && fd->flags & FD_FLAGS_SWITCH_ENDIAN) { int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] * lctex->tex_size[2]; @@ -6513,6 +6513,10 @@ static void direct_link_lightcache_texture(FileData *fd, LightCacheTexture *lcte } } } + + if (lctex->data == NULL) { + zero_v3_int(lctex->tex_size); + } } static void direct_link_lightcache(FileData *fd, LightCache *cache) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index b97267dc011..424a0e78847 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2555,7 +2555,12 @@ static void write_lightcache_texture(WriteData *wd, LightCacheTexture *tex) else if (tex->data_type == LIGHTCACHETEX_UINT) { data_size *= sizeof(uint); } - writedata(wd, DATA, data_size, tex->data); + + /* FIXME: We can't save more than what 32bit systems can handle. + * The solution would be to split the texture but it is too late for 2.90. (see T78529) */ + if (data_size < INT_MAX) { + writedata(wd, DATA, data_size, tex->data); + } } } |