[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37837] trunk/blender/source/blender/ blenloader/intern/readfile.c: == Multires ==

Nicholas Bishop nicholasbishop at gmail.com
Mon Jun 27 05:54:25 CEST 2011


Revision: 37837
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37837
Author:   nicholasbishop
Date:     2011-06-27 03:54:22 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
== 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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2011-06-27 03:36:14 UTC (rev 37836)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2011-06-27 03:54:22 UTC (rev 37837)
@@ -3538,6 +3538,18 @@
 		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 @@
 		}
 	}
 
-	/* 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) {




More information about the Bf-blender-cvs mailing list