diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-04-21 20:58:25 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2009-04-21 20:58:25 +0400 |
commit | a82a6bedc55fe676c11bf36f1017c0cbddcd9ca2 (patch) | |
tree | 579dde8cef4d86390c7cbe1c97eb267d2ababaee | |
parent | 6c33cc9bae9a565ee2ea5247754c6a4b127795bf (diff) |
Fix for bug #17457. This bug relates to files that have missing multires vertex data.
The fix is, if the file was saved on the highest multires level, then mesh contains a copy of the vertices anyway, and we can just copy it back into multires.
Otherwise, multires is removed from the mesh to avoid a crash.
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 4d312632b1a..8112c64d79f 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -111,7 +111,8 @@ void multires_free(Multires *mr) lvl= lvl->next; } - MEM_freeN(mr->verts); + if(mr->verts) + MEM_freeN(mr->verts); BLI_freelistN(&mr->levels); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index c88e06a9993..477f5a6cb59 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2876,6 +2876,18 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) lvl->map_mem= NULL; } } + + /* Gracefully handle corrupted mesh */ + if(mesh->mr && !mesh->mr->verts) { + /* If totals match, simply load the current mesh verts into multires */ + if(mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert) + mesh->mr->verts = MEM_dupallocN(mesh->mvert); + else { + /* Otherwise, we can't recover the data, silently remove multires */ + multires_free(mesh->mr); + mesh->mr = NULL; + } + } if((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) { TFace *tf= mesh->tface; |