[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22914] branches/bmesh/blender/source/ blender: brought weight paint back.
Joseph Eagar
joeedh at gmail.com
Mon Aug 31 17:57:14 CEST 2009
Revision: 22914
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22914
Author: joeedh
Date: 2009-08-31 17:57:13 +0200 (Mon, 31 Aug 2009)
Log Message:
-----------
brought weight paint back.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c
branches/bmesh/blender/source/blender/makesdna/DNA_customdata_types.h
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2009-08-31 15:54:56 UTC (rev 22913)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/DerivedMesh.c 2009-08-31 15:57:13 UTC (rev 22914)
@@ -1784,23 +1784,45 @@
static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm)
{
Mesh *me = ob->data;
- MFace *mf = me->mface;
+ MFace *mf = dm->getTessFaceArray(dm);
+ DMFaceIter *dfiter;
+ DMLoopIter *dliter;
ColorBand *coba= stored_cb; /* warning, not a local var */
unsigned char *wtcol;
- int i;
+ unsigned char(*wlcol)[4] = NULL;
+ V_DECLARE(wlcol);
+ int i, totface=dm->getNumTessFaces(dm), totpoly=dm->getNumFaces, totloop;
+ int *origIndex = dm->getVertDataArray(dm, CD_ORIGINDEX);
- wtcol = MEM_callocN (sizeof (unsigned char) * me->totface*4*4, "weightmap");
+ wtcol = MEM_callocN (sizeof (unsigned char) * totface*4*4, "weightmap");
- memset(wtcol, 0x55, sizeof (unsigned char) * me->totface*4*4);
- for (i=0; i<me->totface; i++, mf++) {
- 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]);
+ /*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]);
}
- CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, dm->numFaceData);
+ CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol, totface);
+
+ /*now add to loops, so the data can be passed through the modifier stack*/
+ totloop = 0;
+ dfiter = dm->newFaceIter(dm);
+ for (; !dfiter->done; dfiter->step(dfiter)) {
+ 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]);
+ }
+ }
+
+ CustomData_add_layer(&dm->loopData, CD_WEIGHT_MLOOPCOL, CD_ASSIGN, wlcol, totloop);
}
/* new value for useDeform -1 (hack for the gameengine):
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2009-08-31 15:54:56 UTC (rev 22913)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/cdderivedmesh.c 2009-08-31 15:57:13 UTC (rev 22914)
@@ -1089,7 +1089,6 @@
int cdindex, BMLoop *l3[3],
int numCol, int numTex)
{
- int i, j;
BMLoop *l;
BMFace *f = l3[0]->f;
MTFace *texface;
@@ -1097,6 +1096,7 @@
MCol *mcol;
MLoopCol *mloopcol;
MLoopUV *mloopuv;
+ int i, j, hasWCol = CustomData_has_layer(&bm->ldata, CD_WEIGHT_MLOOPCOL);
for(i=0; i < numTex; i++){
texface = CustomData_get_n(facedata, CD_MTFACE, cdindex, i);
@@ -1129,6 +1129,19 @@
mcol[j].a = mloopcol->a;
}
}
+
+ if (hasWCol) {
+ mcol = CustomData_get(facedata, cdindex, CD_WEIGHT_MCOL);
+
+ for (j=0; j<3; j++) {
+ l = l3[j];
+ mloopcol = CustomData_bmesh_get(&bm->ldata, l->head.data, CD_WEIGHT_MLOOPCOL);
+ mcol[j].r = mloopcol->r;
+ mcol[j].g = mloopcol->g;
+ mcol[j].b = mloopcol->b;
+ mcol[j].a = mloopcol->a;
+ }
+ }
}
DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *me)
@@ -1166,15 +1179,9 @@
CustomData_merge(&em->bm->pdata, &dm->polyData, CD_MASK_DERIVEDMESH,
CD_CALLOC, dm->numPolyData);
- /*add tesselation mface and mcol layers as necassary*/
- for (i=0; i<numTex; i++) {
- CustomData_add_layer(&dm->faceData, CD_MTFACE, CD_CALLOC, NULL, em->tottri);
- }
+ /*add tesselation mface layers*/
+ CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri);
- for (i=0; i<numCol; i++) {
- CustomData_add_layer(&dm->faceData, CD_MCOL, CD_CALLOC, NULL, em->tottri);
- }
-
/* set vert index */
eve = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, NULL);
for (i=0; eve; eve=BMIter_Step(&iter), i++)
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2009-08-31 15:54:56 UTC (rev 22913)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c 2009-08-31 15:57:13 UTC (rev 22914)
@@ -867,6 +867,9 @@
layerSwap_mcol, layerDefault_mcol},
{sizeof(MPoly), "MPoly", 1, "NGon Face", NULL, NULL, NULL, NULL, NULL},
{sizeof(MLoop), "MLoop", 1, "NGon Face-Vertex", NULL, NULL, NULL, NULL, NULL},
+ {sizeof(MLoopCol), "MLoopCol", 1, "WeightLoopCol", NULL, NULL, layerInterp_mloopcol, NULL,
+ layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol,
+ layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol},
};
const char *LAYERTYPENAMES[CD_NUMTYPES] = {
@@ -890,7 +893,7 @@
const CustomDataMask CD_MASK_DERIVEDMESH =
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE |
CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
- CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
+ CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_WEIGHT_MLOOPCOL |
CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO | CD_MASK_TANGENT | CD_MASK_WEIGHT_MCOL;
const CustomDataMask CD_MASK_BMESH = CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY |
CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR;
@@ -2003,6 +2006,8 @@
for(i=0; i < ldata->totlayer; i++){
if(ldata->layers[i].type == CD_MLOOPCOL)
CustomData_add_layer(fdata, CD_MCOL, CD_CALLOC, &(ldata->layers[i].name), total);
+ if (ldata->layers[i].type == CD_WEIGHT_MLOOPCOL)
+ CustomData_add_layer(fdata, CD_WEIGHT_MCOL, CD_CALLOC, &(ldata->layers[i].name), total);
}
}
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2009-08-31 15:54:56 UTC (rev 22913)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/mesh.c 2009-08-31 15:57:13 UTC (rev 22914)
@@ -1409,7 +1409,7 @@
MCol *mcol;
MLoopCol *mloopcol;
MLoopUV *mloopuv;
- int i, j;
+ int i, j, hasWCol = CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL);
for(i=0; i < numTex; i++){
texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
@@ -1440,6 +1440,18 @@
mcol[j].a = mloopcol->a;
}
}
+
+ if (hasWCol) {
+ mcol = CustomData_get(fdata, findex, CD_WEIGHT_MCOL);
+
+ for (j=0; j<3; j++) {
+ mloopcol = CustomData_get(ldata, lindex[j], CD_WEIGHT_MLOOPCOL);
+ mcol[j].r = mloopcol->r;
+ mcol[j].g = mloopcol->g;
+ mcol[j].b = mloopcol->b;
+ mcol[j].a = mloopcol->a;
+ }
+ }
}
/*this function recreates a tesselation.
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c 2009-08-31 15:54:56 UTC (rev 22913)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c 2009-08-31 15:57:13 UTC (rev 22914)
@@ -133,10 +133,10 @@
bmold = *bm;
/*merge custom data layout*/
- CustomData_bmesh_merge(&dm->vertData, &bm->vdata, CD_MASK_BMESH|CD_MASK_ORIGINDEX, CD_CALLOC, bm, BM_VERT);
- CustomData_bmesh_merge(&dm->edgeData, &bm->edata, CD_MASK_BMESH|CD_MASK_ORIGINDEX, CD_CALLOC, bm, BM_EDGE);
- CustomData_bmesh_merge(&dm->loopData, &bm->ldata, CD_MASK_BMESH|CD_MASK_ORIGINDEX, CD_CALLOC, bm, BM_LOOP);
- CustomData_bmesh_merge(&dm->polyData, &bm->pdata, CD_MASK_BMESH|CD_MASK_ORIGINDEX, CD_CALLOC, bm, BM_FACE);
+ CustomData_bmesh_merge(&dm->vertData, &bm->vdata, CD_MASK_DERIVEDMESH, CD_CALLOC, bm, BM_VERT);
+ CustomData_bmesh_merge(&dm->edgeData, &bm->edata, CD_MASK_DERIVEDMESH, CD_CALLOC, bm, BM_EDGE);
+ CustomData_bmesh_merge(&dm->loopData, &bm->ldata, CD_MASK_DERIVEDMESH, CD_CALLOC, bm, BM_LOOP);
+ CustomData_bmesh_merge(&dm->polyData, &bm->pdata, CD_MASK_DERIVEDMESH, CD_CALLOC, bm, BM_FACE);
/*needed later*/
numTex = CustomData_number_of_layers(&bm->pdata, CD_MTEXPOLY);
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2009-08-31 15:54:56 UTC (rev 22913)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/subsurf_ccg.c 2009-08-31 15:57:13 UTC (rev 22914)
@@ -2561,7 +2561,7 @@
MCol *mcol;
MLoopCol *mloopcol;
MLoopUV *mloopuv;
- int i, j;
+ int i, j, hasWCol = CustomData_has_layer(ldata, CD_WEIGHT_MLOOPCOL);
for(i=0; i < numTex; i++){
texface = CustomData_get_n(fdata, CD_MTFACE, findex, i);
@@ -2592,6 +2592,18 @@
mcol[j].a = mloopcol->a;
}
}
+
+ if (hasWCol) {
+ mloopcol = CustomData_get(ldata, loopstart, CD_WEIGHT_MLOOPCOL);
+ mcol = CustomData_get(fdata, findex, CD_WEIGHT_MCOL);
+
+ for (j=0; j<4; j++, mloopcol++) {
+ mcol[j].r = mloopcol->r;
+ mcol[j].g = mloopcol->g;
+ mcol[j].b = mloopcol->b;
+ mcol[j].a = mloopcol->a;
+ }
+ }
}
/*this function requires dm to be a CDDM*/
Modified: branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2009-08-31 15:54:56 UTC (rev 22913)
+++ branches/bmesh/blender/source/blender/editors/sculpt_paint/paint_vertex.c 2009-08-31 15:57:13 UTC (rev 22914)
@@ -1380,22 +1380,22 @@
if(wp->flag & VP_COLINDEX) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list