[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22931] branches/bmesh/blender/source/ blender: some merge, vpaint and wpaint bugfixes

Joseph Eagar joeedh at gmail.com
Tue Sep 1 18:05:33 CEST 2009


Revision: 22931
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22931
Author:   joeedh
Date:     2009-09-01 18:05:33 +0200 (Tue, 01 Sep 2009)

Log Message:
-----------
some merge, vpaint and wpaint bugfixes

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
    branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c
    branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
    branches/bmesh/blender/source/blender/editors/mesh/mesh_layers.c
    branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2009-09-01 14:59:50 UTC (rev 22930)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c	2009-09-01 16:05:33 UTC (rev 22931)
@@ -423,8 +423,7 @@
 		CustomData_add_layer(&tmp.edata, CD_MEDGE, CD_ASSIGN, dm->dupEdgeArray(dm), totedge);
 	if(!CustomData_has_layer(&tmp.fdata, CD_MFACE))
 		CustomData_add_layer(&tmp.fdata, CD_MFACE, CD_ASSIGN, dm->dupTessFaceArray(dm), totface);
-	
-	if(!CustomData_has_layer(&tmp.fdata, CD_MPOLY))
+	if(!CustomData_has_layer(&tmp.pdata, CD_MPOLY))
 		dm_add_polys_from_iter(&tmp.ldata, &tmp.pdata, dm, totloop);
 
 	mesh_update_customdata_pointers(&tmp);
@@ -1801,14 +1800,11 @@
 	/*first add colors to the tesselation faces*/
 	memset(wtcol, 0x55, sizeof (unsigned char) * totface*4*4);
 	for (i=0; i<totface; i++, mf++) {
-		if (origIndex[mf->v1] != ORIGINDEX_NONE)
-			calc_weightpaint_vert_color(ob, coba, origIndex[mf->v1], &wtcol[(i*4 + 0)*4]); 
-		if (origIndex[mf->v2] != ORIGINDEX_NONE)
-			calc_weightpaint_vert_color(ob, coba, origIndex[mf->v2], &wtcol[(i*4 + 1)*4]); 
-		if (origIndex[mf->v3] != ORIGINDEX_NONE)
-			calc_weightpaint_vert_color(ob, coba, origIndex[mf->v3], &wtcol[(i*4 + 2)*4]); 
-		if (mf->v4 && origIndex[mf->v4] != ORIGINDEX_NONE)
-			calc_weightpaint_vert_color(ob, coba, origIndex[mf->v4], &wtcol[(i*4 + 3)*4]); 
+		calc_weightpaint_vert_color(ob, coba, mf->v1, &wtcol[(i*4 + 0)*4]); 
+		calc_weightpaint_vert_color(ob, coba, mf->v2, &wtcol[(i*4 + 1)*4]); 
+		calc_weightpaint_vert_color(ob, coba, mf->v3, &wtcol[(i*4 + 2)*4]); 
+		if (mf->v4)
+			calc_weightpaint_vert_color(ob, coba, mf->v4, &wtcol[(i*4 + 3)*4]); 
 	}
 	
 	CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, totface);
@@ -1820,7 +1816,7 @@
 		dliter = dfiter->getLoopsIter(dfiter);
 		for (; !dliter->done; dliter->step(dliter), totloop++) {
 			V_GROW(wlcol);
-			calc_weightpaint_vert_color(ob, coba, origIndex[dliter->vindex], &wlcol[totloop]);			 
+			calc_weightpaint_vert_color(ob, coba, dliter->vindex, &wlcol[totloop]);			 
 		}
 	}
 
@@ -2049,9 +2045,6 @@
 
 		CDDM_apply_vert_coords(finaldm, deformedVerts);
 		CDDM_calc_normals(finaldm);
-
-		if(dataMask & CD_MASK_WEIGHT_MCOL)
-			add_weight_mcol_dm(ob, finaldm);
 	} else if(dm) {
 		finaldm = dm;
 	} else {

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c	2009-09-01 14:59:50 UTC (rev 22930)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c	2009-09-01 16:05:33 UTC (rev 22931)
@@ -1458,9 +1458,9 @@
 
   returns number of tesselation faces.*/
 int mesh_recalcTesselation(CustomData *fdata, 
-				   CustomData *ldata, CustomData *pdata,
-				   MVert *mvert, int totface, int totloop, 
-				   int totpoly)
+                           CustomData *ldata, CustomData *pdata,
+                           MVert *mvert, int totface, int totloop, 
+                           int totpoly)
 {
 	MPoly *mp, *mpoly;
 	MLoop *ml, *mloop;

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c	2009-09-01 14:59:50 UTC (rev 22930)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c	2009-09-01 16:05:33 UTC (rev 22931)
@@ -236,6 +236,14 @@
 
 int BM_Vert_FaceCount(BMVert *v){
 	int count = 0;
+	BMLoop *l;
+	BMIter iter;
+
+	BM_ITER(l, &iter, NULL, BM_LOOPS_OF_VERT, v)
+		count++;
+
+	return count;
+#if 0 //this code isn't working
 	BMEdge *curedge = NULL;
 
 	if(v->edge){
@@ -246,6 +254,7 @@
 		}while(curedge != v->edge);
 	}
 	return count;
+#endif
 }
 
 /**

Modified: branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2009-09-01 14:59:50 UTC (rev 22930)
+++ branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c	2009-09-01 16:05:33 UTC (rev 22931)
@@ -2596,5 +2596,5 @@
 	/* properties */
 	prop= RNA_def_enum(ot->srna, "type", merge_type_items, 3, "Type", "Merge method to use.");
 	RNA_def_enum_funcs(prop, merge_type_itemf);
-	RNA_def_boolean(ot->srna, "uvs", 0, "UVs", "Move UVs according to merge.");
+	RNA_def_boolean(ot->srna, "uvs", 1, "UVs", "Move UVs according to merge.");
 }

Modified: branches/bmesh/blender/source/blender/editors/mesh/mesh_layers.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/mesh/mesh_layers.c	2009-09-01 14:59:50 UTC (rev 22930)
+++ branches/bmesh/blender/source/blender/editors/mesh/mesh_layers.c	2009-09-01 16:05:33 UTC (rev 22931)
@@ -157,6 +157,14 @@
 		/* set index */
 		CustomData_set_layer_mask(data, type, maskindex);
 	}
+
+	if (!me->edit_btmesh) {
+		/*recalc mesh tesselation*/
+		me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, 
+			&me->pdata, me->mvert, me->totface, me->totloop, me->totpoly);
+
+		mesh_update_customdata_pointers(me);
+	}
 }
 
 /*********************** UV texture operators ************************/
@@ -199,6 +207,10 @@
 		}
 		
 		CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum);
+
+		/*recalc mesh tesselation*/
+		me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, 
+			&me->pdata, me->mvert, me->totface, me->totloop, me->totpoly);
 		mesh_update_customdata_pointers(me);
 	}
 
@@ -305,6 +317,11 @@
 			CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop);
 
 		CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum);
+
+		/*recalc mesh tesselation*/
+		me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, 
+			&me->pdata, me->mvert, me->totface, me->totloop, me->totpoly);
+		
 		mesh_update_customdata_pointers(me);
 
 		//if(!mcol)

Modified: branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2009-09-01 14:59:50 UTC (rev 22930)
+++ branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2009-09-01 16:05:33 UTC (rev 22931)
@@ -216,7 +216,7 @@
 	/* if no mloopcol: do not do */
 	/* if mtexpoly: only the involved faces, otherwise all */
 
-	if(me->mloopcol==0 || me->totvert==0 || me->totface==0) return;
+	if(me->mloopcol==0 || me->totvert==0 || me->totpoly==0) return;
 
 	scol = MEM_callocN(sizeof(float)*me->totvert*5, "scol");
 
@@ -248,7 +248,7 @@
 	ml = me->mloop;
 	lcol = me->mloopcol;
 	for (i=0; i<me->totloop; i++, ml++, lcol++) {
-		if (!scol[4]) continue;
+		if (!scol[ml->v][4]) continue;
 
 		lcol->r = scol[ml->v][0];
 		lcol->g = scol[ml->v][1];
@@ -339,12 +339,14 @@
 	if(me==0) return;
 
 	/* copies from shadedisplist to mcol */
-	if(!me->mcol) {
+	if(!me->mcol)
 		CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
+	if (!me->mloopcol)
 		CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, me->totloop);
-		mesh_update_customdata_pointers(me);
-	}
+	
+	mesh_update_customdata_pointers(me);
 
+
 	/*
 	if(shade)
 		shadeMeshMCol(scene, ob, me);
@@ -390,7 +392,7 @@
 void clear_vpaint(Scene *scene, int selected)
 {
 	Mesh *me;
-	MFace *mf;
+ 	MFace *mf;
 	MPoly *mp;
 	MLoopCol *lcol;
 	Object *ob;
@@ -1691,7 +1693,7 @@
 
 	/* context checks could be a poll() */
 	me= get_mesh(ob);
-	if(me==NULL || me->totface==0)
+	if(me==NULL || me->totpoly==0)
 		return OPERATOR_PASS_THROUGH;
 	
 	if(me->mloopcol==NULL)
@@ -1750,7 +1752,7 @@
 			
 	/* which faces are involved */
 	if(vp->flag & VP_AREA) {
-		totindex= sample_backbuf_area(vc, indexar, me->totface, mval[0], mval[1], brush->size);
+		totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush->size);
 	}
 	else {
 		indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]);
@@ -1762,7 +1764,7 @@
 			
 	if(vp->flag & VP_COLINDEX) {
 		for(index=0; index<totindex; index++) {
-			if(indexar[index] && indexar[index]<=me->totface) {
+			if(indexar[index] && indexar[index]<=me->totpoly) {
 				MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1);
 						
 				if(mpoly->mat_nr!=ob->actcol-1) {
@@ -1773,7 +1775,7 @@
 	}
 	if((G.f & G_FACESELECT) && me->mface) {
 		for(index=0; index<totindex; index++) {
-			if(indexar[index] && indexar[index]<=me->totface) {
+			if(indexar[index] && indexar[index]<=me->totpoly) {
 				MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1);
 						
 				if((mpoly->flag & ME_FACE_SEL)==0)
@@ -1784,7 +1786,7 @@
 			
 	for(index=0; index<totindex; index++) {
 				
-		if(indexar[index] && indexar[index]<=me->totface) {
+		if(indexar[index] && indexar[index]<=me->totpoly) {
 			MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1);
 			MFace *mf;
 			MCol *mc;





More information about the Bf-blender-cvs mailing list