Fix vertex paint face selection

This commit is contained in:
Andrew Wiggin
2011-10-14 09:05:20 +00:00
parent f3c8f3d663
commit c4cb393e45
3 changed files with 64 additions and 42 deletions

View File

@@ -1667,6 +1667,7 @@ static void write_meshs(WriteData *wd, ListBase *idbase)
write_customdata(wd, &mesh->id, mesh->pv->totvert, &mesh->vdata, -1, 0);
write_customdata(wd, &mesh->id, mesh->pv->totedge, &mesh->edata,
CD_MEDGE, mesh->totedge);
/* BMESH_TODO: probably need to deal with polys here */
write_customdata(wd, &mesh->id, mesh->pv->totface, &mesh->fdata,
CD_MFACE, mesh->totface);
}

View File

@@ -360,14 +360,13 @@ static int isect_point_quad_v2_d(double pt[2], double v1[2], double v2[2], doubl
mdisps is a grid of displacements, ordered thus:
v1/center -- v4/next -> x
| |
| |
v2/prev ---- v3/cur
|
V
y
v1/center----v4/next -> x
| |
| |
v2/prev------v3/cur
|
V
y
*/
static int compute_mdisp_quad(BMLoop *l, double v1[3], double v2[3], double v3[3], double v4[3], double e1[3], double e2[3])
@@ -611,15 +610,15 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f)
/*****
mdisps is a grid of displacements, ordered thus:
v4/next
|
| v1/cent-mid2 ---> x
| | |
| | |
v2/prev--mid1--v3/cur
|
V
y
v4/next
|
| v1/cent-----mid2 ---> x
| | |
| | |
v2/prev---mid1-----v3/cur
|
V
y
*****/
sides = sqrt(mdp->totdisp);
@@ -642,15 +641,15 @@ void BM_multires_smooth_bounds(BMesh *bm, BMFace *f)
/*****
mdisps is a grid of displacements, ordered thus:
v4/next
|
| v1/cent-mid2 ---> x
| | |
| | |
v2/prev--mid1--v3/cur
|
V
y
v4/next
|
| v1/cent-----mid2 ---> x
| | |
| | |
v2/prev---mid1-----v3/cur
|
V
y
*****/
if (l->radial_next == l)
@@ -737,8 +736,8 @@ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source,
else if(yn>=xn && yn>=zn) {ax= 0; ay= 2;}
else {ax= 1; ay= 2;}
/*scale source face coordinates a bit, so points sitting directonly on an
edge will work.*/
/* scale source face coordinates a bit, so points sitting directonly on an
edge will work.*/
mul_v3_fl(cent, 1.0f/(float)source->len);
for (i=0; i<source->len; i++) {
float vec[3], tmp[3];

View File

@@ -69,27 +69,49 @@
/* copy the face flags, most importantly selection from the mesh to the final derived mesh,
* use in object mode when selecting faces (while painting) */
void paintface_flush_flags(Object *ob)
{
Mesh *me= get_mesh(ob);
DerivedMesh *dm= ob->derivedFinal;
MPoly *mf_orig, *mp;
int *index = NULL;
int totface;
Mesh *me = get_mesh(ob);
DerivedMesh *dm = ob->derivedFinal;
MPoly *polys, *mp_orig;
MFace *faces, *mf;
int *index_array = NULL;
int totface, totpoly;
int i;
if(me==NULL || dm==NULL)
if (me==NULL || dm==NULL) {
return;
}
totface = dm->getNumFaces(dm);
index = DM_get_face_data_layer(dm, CD_ORIGINDEX);
mp = dm->getPolyArray(dm);
for (i=0; i<dm->numPolyData; i++, index++, mp++) {
if (!index)
break;
/*
* Try to push updated mesh poly flags to two other data sets:
* - Mesh polys => Mesh tess faces
* - Mesh polys => Final derived mesh polys
*/
mf_orig = me->mpoly + *index;
mp->flag = mf_orig->flag;
if (index_array = CustomData_get_layer(&me->fdata, CD_ORIGINDEX)) {
faces = me->mface;
totface = me->totface;
/* loop over tessfaces */
for (i= 0; i<totface; i++) {
/* Copy flags onto the tessface from its poly */
mp_orig = me->mpoly + index_array[i];
faces[i].flag = mp_orig->flag;
}
}
if (index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX)) {
polys = dm->getPolyArray(dm);
totpoly = dm->getNumFaces(dm);
/* loop over final derived polys */
for (i= 0; i<totpoly; i++) {
/* Copy flags onto the mesh poly from its final derived poly */
mp_orig = me->mpoly + index_array[i];
polys[i].flag = mp_orig->flag;
}
}
}