Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2011-06-27 07:54:22 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2011-06-27 07:54:22 +0400
commitd7cea716c57a7195312fb327d3294bc8b9981a68 (patch)
tree100e4289815906da8fca7d94642c54f7b795cd17 /source/blender/blenloader
parent33e554799bd69e888b5114ba92871f8de94a8597 (diff)
== Multires ==
Fix for bug #27710, 'Multires lost from 2.49 file in 2.5x' Reported by Gaia Clary. Problem was that the old multires data didn't flush changes to vertices out to the Multires structure on filesave. So, recent bits of sculpting could be lost if the multires level wasn't changed before filesave. We already had code to deal with missing multires vertex data, which simply copies the Mesh vertex data into the multires vertex data if it matches the number of vertices in the highest level. Moved this code up a bit so that we always make this copy if the numbers match up. Was able to reproduce the bug fresh in 2.49b, and confirmed that the fix works. However, this does not help if changes were sculpted on a multires level other than the highest level and saved without a subsequent level change.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bd1764b2dc9..2637e114fbc 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3538,6 +3538,18 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
mesh->mr->edge_creases= newdataadr(fd, mesh->mr->edge_creases);
mesh->mr->verts = newdataadr(fd, mesh->mr->verts);
+
+ /* If mesh has the same number of vertices as the
+ highest multires level, load the current mesh verts
+ into multires and discard the old data. Needed
+ because some saved files either do not have a verts
+ array, or the verts array contains out-of-date
+ data. */
+ if(mesh->totvert == ((MultiresLevel*)mesh->mr->levels.last)->totvert) {
+ if(mesh->mr->verts)
+ MEM_freeN(mesh->mr->verts);
+ mesh->mr->verts = MEM_dupallocN(mesh->mvert);
+ }
for(; lvl; lvl= lvl->next) {
lvl->verts= newdataadr(fd, lvl->verts);
@@ -3547,16 +3559,11 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
}
}
- /* Gracefully handle corrupted mesh */
+ /* if multires is present but has no valid vertex data,
+ there's no way to recover it; silently remove multires */
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;
- }
+ multires_free(mesh->mr);
+ mesh->mr = NULL;
}
if((fd->flags & FD_FLAGS_SWITCH_ENDIAN) && mesh->tface) {