Commit: 220470be1515d90ae2c3157648bd9da311925427
Author: Clément Foucault
Date:   Wed Aug 5 02:25:31 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB220470be1515d90ae2c3157648bd9da311925427

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

===================================================================

M       source/blender/blenloader/intern/readfile.c
M       source/blender/blenloader/intern/writefile.c

===================================================================

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);
+    }
   }
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to