[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19553] trunk/blender/source/blender/ blenkernel/intern/constraint.c: 2. 4x Bugfix #18279 - Copy Vertex Group Location doesn' t work with subsurf modifier

Joshua Leung aligorith at gmail.com
Mon Apr 6 02:22:58 CEST 2009


Revision: 19553
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19553
Author:   aligorith
Date:     2009-04-06 02:22:58 +0200 (Mon, 06 Apr 2009)

Log Message:
-----------
2.4x Bugfix #18279 - Copy Vertex Group Location doesn't work with subsurf modifier

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/constraint.c

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2009-04-06 00:10:52 UTC (rev 19552)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2009-04-06 00:22:58 UTC (rev 19553)
@@ -540,6 +540,7 @@
 	float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3];
 	float imat[3][3], tmat[3][3];
 	int dgroup;
+	short freeDM = 0;
 	
 	/* initialize target matrix using target matrix */
 	Mat4CpyMat4(mat, ob->obmat);
@@ -552,10 +553,19 @@
 	if ((G.obedit == ob) && (G.editMesh)) {
 		/* target is in editmode, so get a special derived mesh */
 		dm = CDDM_from_editmesh(G.editMesh, ob->data);
+		freeDM= 1;
 	}
 	else {
-		/* when not in EditMode, this should exist */
-		dm = (DerivedMesh *)ob->derivedFinal;
+		/* when not in EditMode, use the 'final' derived mesh 
+		 *	- check if the custom data masks for derivedFinal mean that we can just use that
+		 *	  (this is more effficient + sufficient for most cases)
+		 */
+		if (ob->lastDataMask != CD_MASK_DERIVEDMESH) {
+			dm = mesh_get_derived_final(ob, CD_MASK_DERIVEDMESH);
+			freeDM= 1;
+		}
+		else 
+			dm = (DerivedMesh *)ob->derivedFinal;
 	}
 	
 	/* only continue if there's a valid DerivedMesh */
@@ -620,10 +630,9 @@
 		}
 	}
 	
-	/* free temporary DerivedMesh created (in EditMode case) */
-	if (G.editMesh) {
-		if (dm) dm->release(dm);
-	}
+	/* free temporary DerivedMesh created */
+	if (dm && freeDM) 
+		dm->release(dm);
 }
 
 /* function that sets the given matrix based on given vertex group in lattice */





More information about the Bf-blender-cvs mailing list