[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43233] trunk/blender/source/blender/ blenkernel/intern/DerivedMesh.c: have add_weight_mcol_dm() set the 4th corner of a tri faces color to 0, otherwise uninitialized memory gets copied about.

Campbell Barton ideasman42 at gmail.com
Mon Jan 9 11:38:23 CET 2012


Revision: 43233
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43233
Author:   campbellbarton
Date:     2012-01-09 10:38:22 +0000 (Mon, 09 Jan 2012)
Log Message:
-----------
have add_weight_mcol_dm() set the 4th corner of a tri faces color to 0, otherwise uninitialized memory gets copied about.

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

Modified: trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-09 10:30:27 UTC (rev 43232)
+++ trunk/blender/source/blender/blenkernel/intern/DerivedMesh.c	2012-01-09 10:38:22 UTC (rev 43233)
@@ -761,14 +761,28 @@
 	Mesh *me = ob->data;
 	unsigned char *wtcol_v = calc_weightpaint_vert_array(ob, draw_flag, coba);
 	unsigned char *wtcol_f = MEM_mallocN (sizeof(unsigned char) * me->totface*4*4, "weightmap_f");
+	unsigned char *wtcol_f_step = wtcol_f;
 
 	MFace *mf = me->mface;
 	int i;
 
-	for (i=0; i<me->totface; i++, mf++) {
+	for (i=0; i<me->totface; i++, mf++, wtcol_f_step += (4 * 4)) {
+#if 0
 		unsigned int fidx= mf->v4 ? 3:2;
+
+#else	/* better zero out triangles 4th component. else valgrind complains when the buffer's copied */
+		unsigned int fidx;
+		if (mf->v4) {
+			fidx = 3;
+		}
+		else {
+			fidx = 2;
+			*(int *)(&wtcol_f_step[3 * 4]) = 0;
+		}
+#endif
+
 		do {
-			copy_v4_v4_char((char *)&wtcol_f[(4 * i + fidx) * 4],
+			copy_v4_v4_char((char *)&wtcol_f_step[fidx * 4],
 			                (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]);
 		} while (fidx--);
 	}



More information about the Bf-blender-cvs mailing list