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.
This commit is contained in:
Nicholas Bishop
2009-04-21 16:58:25 +00:00
parent 6c33cc9bae
commit a82a6bedc5
2 changed files with 14 additions and 1 deletions

View File

@@ -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);

View File

@@ -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;