diff options
Diffstat (limited to 'source/blender/blenloader/intern/versioning_290.c')
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index aaf4ecbf255..7f2b1714245 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -33,6 +33,7 @@ #include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_types.h" #include "DNA_hair_types.h" +#include "DNA_mesh_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_pointcloud_types.h" @@ -47,6 +48,8 @@ #include "BKE_main.h" #include "BKE_node.h" +#include "MEM_guardedalloc.h" + #include "BLO_readfile.h" #include "readfile.h" @@ -659,6 +662,23 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } + if (!MAIN_VERSION_ATLEAST(bmain, 291, 4) && MAIN_VERSION_ATLEAST(bmain, 291, 1)) { + /* Due to a48d78ce07f4f, CustomData.totlayer and CustomData.maxlayer has been written + * incorrectly. Fortunately, the size of the layers array has been written to the .blend file + * as well, so we can reconstruct totlayer and maxlayer from that. */ + LISTBASE_FOREACH (Mesh *, mesh, &bmain->meshes) { + mesh->vdata.totlayer = mesh->vdata.maxlayer = MEM_allocN_len(mesh->vdata.layers) / + sizeof(CustomDataLayer); + mesh->edata.totlayer = mesh->edata.maxlayer = MEM_allocN_len(mesh->edata.layers) / + sizeof(CustomDataLayer); + /* We can be sure that mesh->fdata is empty for files written by 2.90. */ + mesh->ldata.totlayer = mesh->ldata.maxlayer = MEM_allocN_len(mesh->ldata.layers) / + sizeof(CustomDataLayer); + mesh->pdata.totlayer = mesh->pdata.maxlayer = MEM_allocN_len(mesh->pdata.layers) / + sizeof(CustomDataLayer); + } + } + /** * Versioning code until next subversion bump goes here. * |