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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user