diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-08-22 08:45:19 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-08-22 08:45:19 +0400 |
commit | 8151a5168422d6b1f974d238f37707f7bc507db7 (patch) | |
tree | 91460edcb532deeb97646fe51f03e5fefe3ed290 /source/blender/blenkernel | |
parent | 1aeb5a6925322faca0fe263c9cf822dfa545e3ab (diff) |
Shift-G (select similar) is now bmeshafied for face select mode.
The patch was by Wael El Oraiby, who did a great job on it.
Yay for Wael! Commit of patch #19242.
There's also some CCGSubSurf stuff mixed in with this, though it's
still not working right (fixed tons of bugs, just the main ones
for some reason are still there, despite their original causes
being fixed :-/).
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifiers_bmesh.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 70 |
4 files changed, 52 insertions, 37 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index ca6dc9407ff..f1117a967fd 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -285,7 +285,7 @@ void dm_add_polys_from_iter(CustomData *ldata, CustomData *pdata, DerivedMesh *d CustomData *oldata, *opdata; MPoly *mpoly; MLoop *mloop; - int l, i, j, lasttype; + int p, l, i, j, lasttype; oldata = dm->getLoopDataLayout(dm); opdata = dm->getFaceDataLayout(dm); @@ -299,7 +299,7 @@ void dm_add_polys_from_iter(CustomData *ldata, CustomData *pdata, DerivedMesh *d CustomData_add_layer(pdata, CD_MPOLY, CD_ASSIGN, mpoly, dm->getNumFaces(dm)); l = 0; - for (; !iter->done; iter->step(iter), mpoly++) { + for (p=0; !iter->done; iter->step(iter), mpoly++, p++) { mpoly->flag = iter->flags; mpoly->loopstart = l; mpoly->totloop = iter->len; @@ -314,7 +314,10 @@ void dm_add_polys_from_iter(CustomData *ldata, CustomData *pdata, DerivedMesh *d continue; e1 = iter->getCDData(iter, opdata->layers[i].type, j); - e2 = CustomData_get_layer_n(pdata, opdata->layers[i].type, j); + e2 = (char*)CustomData_get_n(pdata, opdata->layers[i].type, p, j); + + if (!e2) + continue; CustomData_copy_elements(opdata->layers[i].type, e1, e2, 1); @@ -340,7 +343,10 @@ void dm_add_polys_from_iter(CustomData *ldata, CustomData *pdata, DerivedMesh *d continue; e1 = liter->getLoopCDData(liter, oldata->layers[i].type, j); - e2 = CustomData_get_layer_n(ldata, oldata->layers[i].type, j); + e2 = CustomData_get_n(ldata, oldata->layers[i].type, l, j); + + if (!e2) + continue; CustomData_copy_elements(oldata->layers[i].type, e1, e2, 1); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 72c3e3b0188..9dc8edb932e 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1644,7 +1644,7 @@ void *CustomData_get_n(const CustomData *data, int type, int index, int n) if(layer_index < 0) return NULL; offset = layerType_getInfo(type)->size * index; - return (char *)data->layers[layer_index].data + offset; + return (char *)data->layers[layer_index+n].data + offset; } void *CustomData_get_layer(const CustomData *data, int type) diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index f69e0efcea6..74a6e920d69 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -193,6 +193,9 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing) verts[j] = vtable[dliter->vindex]; edges[j] = etable[dliter->eindex]; } + + if (j < 2) + break; f = BM_Make_Ngon(bm, verts[0], verts[1], edges, dfiter->len, 0); f->head.flag = MEFlags_To_BMFlags(dfiter->flags, BM_FACE); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index ba53bbe7767..34e517dcf3c 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1460,6 +1460,7 @@ struct cgdm_faceIter; typedef struct cgdm_loopIter { DMLoopIter head; int curloop; + int lindex; //loop index within the mesh, not the face CCGDerivedMesh *cgdm; struct cgdm_faceIter *fiter; } cgdm_loopIter; @@ -1493,7 +1494,7 @@ void cgdm_faceIterStep(void *self) fiter->head.flags = fiter->mface.flag; fiter->head.mat_nr = fiter->mface.mat_nr; - fiter->head.len = fiter->mface.v4 ? 4 : 3; + fiter->head.len = 4; } void *cgdm_faceIterCData(void *self, int type, int layer) @@ -1501,9 +1502,9 @@ void *cgdm_faceIterCData(void *self, int type, int layer) cgdm_faceIter *fiter = self; if (layer == -1) - return CustomData_get(&fiter->cgdm->dm.faceData, fiter->head.index, type); + return CustomData_get(&fiter->cgdm->dm.polyData, fiter->head.index, type); else - return CustomData_get_n(&fiter->cgdm->dm.faceData, type, fiter->head.index, layer); + return CustomData_get_n(&fiter->cgdm->dm.polyData, type, fiter->head.index, layer); } void cgdm_loopIterStep(void *self) @@ -1512,14 +1513,14 @@ void cgdm_loopIterStep(void *self) MFace *mf = &liter->fiter->mface; int i, v1, v2; - if (liter->head.index >= liter->fiter->head.len) { + liter->head.index++; + i = liter->head.index; + + if (liter->head.index >= 4) { liter->head.done = 1; return; } - liter->head.index++; - i = liter->head.index; - switch (i) { case 0: v1 = liter->fiter->mface.v1; @@ -1541,6 +1542,7 @@ void cgdm_loopIterStep(void *self) liter->head.vindex = v1; liter->head.eindex = GET_INT_FROM_POINTER(BLI_edgehash_lookup(liter->fiter->ehash, v1, v2)); + liter->lindex += 1; cgdm_getFinalVert((DerivedMesh*)liter->cgdm, v1, &liter->head.v); } @@ -1557,10 +1559,10 @@ void *cgdm_loopIterGetVCData(void *self, int type, int layer) void *cgdm_loopIterGetCData(void *self, int type, int layer) { cgdm_loopIter *liter = self; - - /*BMESH_TODO - yeek, this has to convert mface-style uv/mcols to loop-style*/ - return NULL; + + if (layer == -1) + return CustomData_get(&liter->cgdm->dm.loopData, liter->lindex, type); + else return CustomData_get_n(&liter->cgdm->dm.loopData, type, liter->lindex, layer); } DMLoopIter *cgdm_faceIterGetLIter(void *self) @@ -1587,6 +1589,8 @@ DMFaceIter *cgdm_newFaceIter(DerivedMesh *dm) MEdge medge; int i, totedge = cgdm_getNumEdges(dm); + fiter->cgdm = dm; + fiter->liter.cgdm = dm; fiter->ehash = BLI_edgehash_new(); for (i=0; i<totedge; i++) { @@ -1604,6 +1608,7 @@ DMFaceIter *cgdm_newFaceIter(DerivedMesh *dm) fiter->liter.head.getLoopCDData = cgdm_loopIterGetCData; fiter->liter.head.getVertCDData = cgdm_loopIterGetVCData; fiter->liter.head.step = cgdm_loopIterStep; + fiter->liter.lindex = -1; fiter->head.step(fiter); } @@ -2627,7 +2632,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, int numTex, numCol; int gridInternalEdges; int index2; - float *w = NULL; + float *w = NULL, one = 1.0f; WeightTable wtable = {0}; V_DECLARE(w); /* MVert *mvert = NULL; - as yet unused */ @@ -2864,12 +2869,13 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, loopindex2++; /*copy over poly data, e.g. mtexpoly*/ - CustomData_interp(&dm->polyData, &cgdm->dm.polyData, &origIndex, w, NULL, 1, index2); + CustomData_interp(&dm->polyData, &cgdm->dm.polyData, &origIndex, &one, NULL, 1, index2); /*generate tesselated face data used for drawing*/ ccg_loops_to_corners(&cgdm->dm.faceData, &cgdm->dm.loopData, &cgdm->dm.polyData, loopindex2-4, index2, index2, numTex, numCol); + faceNum++; index2++; } } @@ -2878,25 +2884,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, edgeNum += numFinalEdges; } - for(index = 0; index < totvert; ++index) { - CCVert *v = cgdm->vertMap[index].vert; - int mapIndex = cgdm_getVertMapIndex(cgdm->ss, v); - int vidx; - - vidx = GET_INT_FROM_POINTER(CCS_getVertVertHandle(v)); - - cgdm->vertMap[index].startVert = vertNum; - - /* set the vert base vert */ - *((int*) CCS_getVertUserData(ss, v)) = vertNum; - - DM_copy_vert_data(dm, &cgdm->dm, vidx, vertNum, 1); - - *vertOrigIndex = mapIndex; - ++vertOrigIndex; - ++vertNum; - } - edgeFlags = DM_get_edge_data_layer(&cgdm->dm, CD_FLAGS); for(index = 0; index < totedge; ++index) { CCEdge *e = cgdm->edgeMap[index].edge; @@ -2938,6 +2925,25 @@ static CCGDerivedMesh *getCCGDerivedMesh(CSubSurf *ss, edgeNum += numFinalEdges; } + + for(index = 0; index < totvert; ++index) { + CCVert *v = cgdm->vertMap[index].vert; + int mapIndex = cgdm_getVertMapIndex(cgdm->ss, v); + int vidx; + + vidx = GET_INT_FROM_POINTER(CCS_getVertVertHandle(v)); + + cgdm->vertMap[index].startVert = vertNum; + + /* set the vert base vert */ + *((int*) CCS_getVertUserData(ss, v)) = vertNum; + + DM_copy_vert_data(dm, &cgdm->dm, vidx, vertNum, 1); + + *vertOrigIndex = mapIndex; + ++vertOrigIndex; + ++vertNum; + } #if 0 for(index = 0; index < totface; ++index) { CCFace *f = cgdm->faceMap[index].face; |