diff options
author | Joseph Eagar <joeedh@gmail.com> | 2009-06-12 18:02:37 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2009-06-12 18:02:37 +0400 |
commit | 80effa20b1161efdfdc6ec464db6b6e1cfdd4359 (patch) | |
tree | 1f4c93c2a9ff2fbbc005c17d82d7a32e84f49d85 | |
parent | f4602926c5c5dbad93eb69b2156ca9224c770b36 (diff) |
moved the active face pointer to BMesh, where I think it belongs. also made some fixes to the ccgsubsurf derivedmesh, and some general modifier bugfixes. note that modifiers are still rather buggy and crashy at the moment, heh :) also made some functions for converting Mesh flags to BMesh flags, and back.
-rw-r--r-- | source/blender/blenkernel/BKE_tessmesh.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/editderivedbmesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 48 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 17 | ||||
-rw-r--r-- | source/blender/blenlib/intern/edgehash.c | 19 | ||||
-rw-r--r-- | source/blender/bmesh/bmesh.h | 10 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 43 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/mesh_conv.c | 38 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 13 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmeshutils.c | 6 |
12 files changed, 130 insertions, 73 deletions
diff --git a/source/blender/blenkernel/BKE_tessmesh.h b/source/blender/blenkernel/BKE_tessmesh.h index 97ff239ca5f..bf940b8c71b 100644 --- a/source/blender/blenkernel/BKE_tessmesh.h +++ b/source/blender/blenkernel/BKE_tessmesh.h @@ -41,9 +41,6 @@ typedef struct BMEditMesh { /*retopo data pointer*/ struct RetopoPaintData *retopo_paint_data; - /*active face pointer*/ - struct BMFace *act_face; - /*index tables, to map indices to elements via EDBM_init_index_arrays and associated functions. don't touch this or read it directly.*/ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 5c34144ca0b..2f54f091883 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1676,7 +1676,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) mp = cddm->mpoly; ml = cddm->mloop; l = 0; - for (i=0; i<cddm->dm.numFaceData; i++, mf++) { + for (i=0; i<cddm->dm.numFaceData; i++, mf++, mp++) { mp->flag = mf->flag; mp->loopstart = l; mp->mat_nr = mf->mat_nr; diff --git a/source/blender/blenkernel/intern/editderivedbmesh.c b/source/blender/blenkernel/intern/editderivedbmesh.c index 34054557e34..29b9918118f 100644 --- a/source/blender/blenkernel/intern/editderivedbmesh.c +++ b/source/blender/blenkernel/intern/editderivedbmesh.c @@ -107,7 +107,6 @@ BMEditMesh *BMEdit_Copy(BMEditMesh *tm) *tm2 = *tm; tm2->derivedCage = tm2->derivedFinal = NULL; - tm2->act_face = NULL; tm2->looptris = NULL; tm2->bm = BM_Copy_Mesh(tm->bm); @@ -214,7 +213,6 @@ void BMEdit_Free(BMEditMesh *em) } em->retopo_paint_data= NULL; - em->act_face = NULL; if (em->looptris) MEM_freeN(em->looptris); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index ed094c2b6ba..9ff7ea0f628 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -575,7 +575,7 @@ static DerivedMesh *buildModifier_applyModifier(ModifierData *md, Object *ob, if(source.v4) source.v4 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v4))); - DM_copy_face_data(dm, result, faceMap[i], i, 1); + DM_copy_tessface_data(dm, result, faceMap[i], i, 1); *dest = source; test_index_face(dest, &result->faceData, i, (orig_v4 ? 4 : 3)); @@ -930,7 +930,7 @@ static DerivedMesh *maskModifier_applyModifier(ModifierData *md, Object *ob, if (source.v4) source.v4 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v4))); - DM_copy_face_data(dm, result, oldIndex, newIndex, 1); + DM_copy_tessface_data(dm, result, oldIndex, newIndex, 1); *dest = source; test_index_face(dest, &result->faceData, newIndex, (orig_v4 ? 4 : 3)); @@ -1366,7 +1366,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, dm->getTessFace(dm, i, &inMF); - DM_copy_face_data(dm, result, i, numFaces, 1); + DM_copy_tessface_data(dm, result, i, numFaces, 1); *mf = inMF; mf->v1 = indexMap[inMF.v1].new; @@ -1402,7 +1402,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, { MFace *mf2 = &mface[numFaces]; - DM_copy_face_data(dm, result, i, numFaces, 1); + DM_copy_tessface_data(dm, result, i, numFaces, 1); *mf2 = *mf; mf2->v1 = calc_mapping(indexMap, inMF.v1, j); @@ -1499,7 +1499,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, } origindex = result->getTessFaceDataArray(result, CD_ORIGINDEX); for(i = 0; i < capFaces; i++) { - DM_copy_face_data(start_cap, result, i, numFaces, 1); + DM_copy_tessface_data(start_cap, result, i, numFaces, 1); mface[numFaces] = cap_mface[i]; mface[numFaces].v1 = vert_map[mface[numFaces].v1]; mface[numFaces].v2 = vert_map[mface[numFaces].v2]; @@ -1600,7 +1600,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, } origindex = result->getTessFaceDataArray(result, CD_ORIGINDEX); for(i = 0; i < capFaces; i++) { - DM_copy_face_data(end_cap, result, i, numFaces, 1); + DM_copy_tessface_data(end_cap, result, i, numFaces, 1); mface[numFaces] = cap_mface[i]; mface[numFaces].v1 = vert_map[mface[numFaces].v1]; mface[numFaces].v2 = vert_map[mface[numFaces].v2]; @@ -1978,7 +1978,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, dm->getTessFace(dm, i, &inMF); - DM_copy_face_data(dm, result, i, numFaces, 1); + DM_copy_tessface_data(dm, result, i, numFaces, 1); *mf = inMF; numFaces++; @@ -1994,7 +1994,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, MFace *mf2 = CDDM_get_tessface(result, numFaces); static int corner_indices[4] = {2, 1, 0, 3}; - DM_copy_face_data(dm, result, i, numFaces, 1); + DM_copy_tessface_data(dm, result, i, numFaces, 1); *mf2 = *mf; mf2->v1 += indexMap[inMF.v1][1]; @@ -2475,7 +2475,7 @@ static DerivedMesh *CDDM_from_smoothmesh(SmoothMesh *mesh) SmoothFace *face = &mesh->faces[i]; MFace *newMF = &new_faces[face->newIndex]; - DM_copy_face_data(mesh->dm, result, + DM_copy_tessface_data(mesh->dm, result, face->oldIndex, face->newIndex, 1); mesh->dm->getTessFace(mesh->dm, face->oldIndex, newMF); @@ -6590,7 +6590,7 @@ static DerivedMesh * particleInstanceModifier_applyModifier( } inMF = orig_mface + i%totface; - DM_copy_face_data(dm, result, i%totface, i, 1); + DM_copy_tessface_data(dm, result, i%totface, i, 1); *mf = *inMF; mf->v1+=(i/totface)*totvert; @@ -6870,7 +6870,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive dm->getTessFace(dm, i, &source); dest = CDDM_get_tessface(splitdm, i); - DM_copy_face_data(dm, splitdm, i, i, 1); + DM_copy_tessface_data(dm, splitdm, i, i, 1); *dest = source; } @@ -6913,7 +6913,7 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive /* ouch! creating new faces & remapping them to new verts is no fun */ if(*fs==1){ df1=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df1=*mf; curdupface++; @@ -6937,12 +6937,12 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive } if(*fs==2){ df1=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df1=*mf; curdupface++; df2=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df2=*mf; curdupface++; @@ -7014,17 +7014,17 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive } else if(*fs==3){ df1=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df1=*mf; curdupface++; df2=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df2=*mf; curdupface++; df3=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df3=*mf; curdupface++; @@ -7115,17 +7115,17 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive df1=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df1=*mf; curdupface++; df2=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df2=*mf; curdupface++; df3=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df3=*mf; curdupface++; @@ -7155,17 +7155,17 @@ static DerivedMesh * explodeModifier_splitEdges(ExplodeModifierData *emd, Derive } else{ df1=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df1=*mf; curdupface++; df2=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df2=*mf; curdupface++; df3=CDDM_get_tessface(splitdm,curdupface); - DM_copy_face_data(splitdm,splitdm,i,curdupface,1); + DM_copy_tessface_data(splitdm,splitdm,i,curdupface,1); *df3=*mf; curdupface++; @@ -7365,7 +7365,7 @@ static DerivedMesh * explodeModifier_explodeMesh(ExplodeModifierData *emd, if(source.v4) source.v4 = edgesplit_get(vertpahash, source.v4, mindex); - DM_copy_face_data(dm,explode,i,i,1); + DM_copy_tessface_data(dm,explode,i,i,1); *mf = source; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 512eea43087..dbdb405d34e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1346,6 +1346,11 @@ void ccgDM_faceIterStep(void *self) { ccgDM_faceIter *fiter = self; + if (!fiter->ccgdm || !fiter->ccgdm->ss) { + fiter->head.done = 1; + return; + } + if (fiter->head.index >= ccgSubSurf_getNumTessFaces(fiter->ccgdm->ss)) { fiter->head.done = 1; return; @@ -2570,19 +2575,21 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ++vertNum; -#if 0 //BMESH_TODO for(S = 0; S < numVerts; S++) { int prevS = (S - 1 + numVerts) % numVerts; int nextS = (S + 1) % numVerts; int otherS = (numVerts == 4) ? (S + 2) % numVerts : 3; + for(x = 1; x < gridFaces; x++) { float w[4]; +#if 0 //BMESH_TODO w[prevS] = weight[x][0][0]; w[S] = weight[x][0][1]; w[nextS] = weight[x][0][2]; w[otherS] = weight[x][0][3]; DM_interp_vert_data(dm, &ccgdm->dm, vertIdx, w, numVerts, vertNum); +#endif *vertOrigIndex = ORIGINDEX_NONE; ++vertOrigIndex; ++vertNum; @@ -2596,24 +2603,25 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, for(y = 1; y < gridFaces; y++) { for(x = 1; x < gridFaces; x++) { float w[4]; +#if 0 //BMESH_TODO w[prevS] = weight[y * gridFaces + x][0][0]; w[S] = weight[y * gridFaces + x][0][1]; w[nextS] = weight[y * gridFaces + x][0][2]; w[otherS] = weight[y * gridFaces + x][0][3]; DM_interp_vert_data(dm, &ccgdm->dm, vertIdx, w, numVerts, vertNum); +#endif *vertOrigIndex = ORIGINDEX_NONE; ++vertOrigIndex; ++vertNum; } } } -#endif + for(i = 0; i < numFinalEdges; ++i) *(int *)DM_get_edge_data(&ccgdm->dm, edgeNum + i, CD_ORIGINDEX) = ORIGINDEX_NONE; -#if 0 //BMESH_TODO for(S = 0; S < numVerts; S++) { int prevS = (S - 1 + numVerts) % numVerts; int nextS = (S + 1) % numVerts; @@ -2626,6 +2634,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, FaceVertWeight w; int j; +#if 0 //BMESH_TODO for(j = 0; j < 4; ++j) { w[j][prevS] = (*weight)[j][0]; w[j][S] = (*weight)[j][1]; @@ -2636,6 +2645,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, DM_interp_tessface_data(dm, &ccgdm->dm, &origIndex, NULL, &w, 1, faceNum); weight++; +#endif *faceOrigIndex = mapIndex; @@ -2644,7 +2654,6 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, } } } -#endif faceFlags[index*4] = mface[origIndex].flag; faceFlags[index*4 + 1] = mface[origIndex].mat_nr; diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index 603c85655d7..8976059d153 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -62,20 +62,19 @@ struct EdgeHash { /***/ EdgeHash *BLI_edgehash_new(void) { - EdgeHash *eh= MEM_mallocN(sizeof(*eh), "EdgeHash"); + EdgeHash *eh= MEM_callocN(sizeof(*eh), "EdgeHash"); eh->cursize= 0; eh->nentries= 0; eh->nbuckets= hashsizes[eh->cursize]; - eh->buckets= malloc(eh->nbuckets*sizeof(*eh->buckets)); - memset(eh->buckets, 0, eh->nbuckets*sizeof(*eh->buckets)); + eh->buckets= MEM_callocN(eh->nbuckets*sizeof(*eh->buckets), "eh buckets 2"); return eh; } void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) { unsigned int hash; - Entry *e= malloc(sizeof(*e)); + Entry *e= MEM_callocN(sizeof(*e), "edgehash e"); if (v1<v0) { v0 ^= v1; @@ -95,7 +94,7 @@ void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) { int i, nold= eh->nbuckets; eh->nbuckets= hashsizes[++eh->cursize]; - eh->buckets= malloc(eh->nbuckets*sizeof(*eh->buckets)); + eh->buckets= MEM_mallocN(eh->nbuckets*sizeof(*eh->buckets), "eh buckets"); memset(eh->buckets, 0, eh->nbuckets*sizeof(*eh->buckets)); for (i=0; i<nold; i++) { @@ -110,7 +109,7 @@ void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val) { } } - free(old); + MEM_freeN(old); } } @@ -155,7 +154,7 @@ void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp) { Entry *n= e->next; if (valfreefp) valfreefp(e->val); - free(e); + MEM_freeN(e); e= n; } @@ -168,7 +167,7 @@ void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp) { void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp) { BLI_edgehash_clear(eh, valfreefp); - free(eh->buckets); + MEM_freeN(eh->buckets); MEM_freeN(eh); } @@ -182,7 +181,7 @@ struct EdgeHashIterator { }; EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) { - EdgeHashIterator *ehi= malloc(sizeof(*ehi)); + EdgeHashIterator *ehi= MEM_mallocN(sizeof(*ehi), "eh iter"); ehi->eh= eh; ehi->curEntry= NULL; ehi->curBucket= -1; @@ -195,7 +194,7 @@ EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh) { return ehi; } void BLI_edgehashIterator_free(EdgeHashIterator *ehi) { - free(ehi); + MEM_freeN(ehi); } void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, int *v0_r, int *v1_r) { diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index 6aca2ee843e..14ff370661f 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -162,6 +162,9 @@ typedef struct BMesh { int stackdepth; /*current depth of operator stack*/ int totflags, walkers; /*total number of tool flag layers*/ ListBase errorstack; + + /*active face pointer*/ + struct BMFace *act_face; } BMesh; typedef struct BMVert { @@ -322,6 +325,13 @@ struct EditMesh *bmesh_to_editmesh(BMesh *bm); /*convert between bmesh and Mesh flags*/ int BMFlags_To_MEFlags(void *element); +/*convert between Mesh and bmesh flags + type must be BM_VERT/BM_EDGE/BM_FACE, + and represents the type of the element + parameter (the three defines map to + MVert, MEdge, and MPoly, respectively).*/ +int MEFlags_To_BMFlags(void *element, int type); + /*include the rest of the API*/ #include "bmesh_filters.h" #include "bmesh_iterators.h" diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index d224979cc09..a00560fa3d5 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -44,6 +44,8 @@ #include "stdio.h" #include "string.h" +#define SELECT 1 + /*prototypes*/ static void bm_copy_loop_attributes(BMesh *source_mesh, BMesh *target_mesh, BMLoop *source_loop, BMLoop *target_loop); @@ -477,6 +479,8 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) for (i=0; i<f->len; i++, l = BMIter_Step(&liter)) { BM_Copy_Attributes(bmold, bm, loops[i], l); } + + if (f == bmold->act_face) bm->act_face = f2; } V_FREE(etable); @@ -487,6 +491,13 @@ BMesh *BM_Copy_Mesh(BMesh *bmold) return bm; } +/* + BM FLAGS TO ME FLAGS + + Returns the flags stored in element, + which much be either a BMVert, BMEdge, + or BMFace, converted to mesh flags. +*/ int BMFlags_To_MEFlags(void *element) { BMHeader *h = element; int f = 0; @@ -507,4 +518,36 @@ int BMFlags_To_MEFlags(void *element) { } return f; +} + +/* + BM FLAGS TO ME FLAGS + + Returns the flags stored in element, + which much be either a MVert, MEdge, + or MPoly, converted to mesh flags. + type must be either BM_VERT, BM_EDGE, + or BM_FACE. +*/ +int MEFlags_To_BMFlags(void *element, int type) { + int f = 0; + + if (type == BM_FACE) { + MPoly *mp = element; + if (mp->flag & ME_FACE_SEL) f |= BM_SELECT; + if (mp->flag & ME_SMOOTH) f |= BM_SMOOTH; + if (mp->flag & ME_HIDE) f |= BM_HIDDEN; + } else if (type == BM_EDGE) { + MEdge *me = element; + if (me->flag & SELECT) f |= BM_SELECT; + if (me->flag & ME_SEAM) f |= BM_SEAM; + if (me->flag & ME_SHARP) f |= BM_SHARP; + if (me->flag & ME_HIDE) f |= BM_HIDDEN; + } else if (type == BM_VERT) { + MVert *mv = element; + if (mv->flag & SELECT) f |= BM_SELECT; + if (mv->flag & ME_HIDE) f |= BM_HIDDEN; + } + + return f; }
\ No newline at end of file diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 5c2e9912c54..06da42e8d6e 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -38,7 +38,7 @@ BMOpDefine def_object_load_bmesh = { BMOpDefine def_mesh_to_bmesh = { "mesh_to_bmesh", {{BMOP_OPSLOT_PNT, "mesh"}, - {0, /*null-terminating sentinel*/}}, + {0, /*null-terminating sentinel*/}}, mesh_to_bmesh_exec, 0 }; diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c index 12a35fa4065..5997a00180a 100644 --- a/source/blender/bmesh/operators/mesh_conv.c +++ b/source/blender/bmesh/operators/mesh_conv.c @@ -36,7 +36,7 @@ */ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { - Mesh *me = BMO_Get_Pnt(op, "me"); + Mesh *me = BMO_Get_Pnt(op, "mesh"); MVert *mvert; MEdge *medge; MLoop *ml; @@ -67,6 +67,8 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { /*Copy Custom Data*/ CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->data); + + v->head.flag = MEFlags_To_BMFlags(mvert, BM_VERT); } if (!me->totedge) return; @@ -84,10 +86,7 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { e->crease = (float)medge->crease / 255.0f; e->bweight = (float)medge->bweight / 255.0f; - if (medge->flag & SELECT) BM_Select_Edge(bm, e, 1); - if (medge->flag & ME_HIDE) BM_SetHFlag(e, BM_HIDDEN); - if (medge->flag & ME_SHARP) BM_SetHFlag(e, BM_SHARP); - if (medge->flag & ME_SEAM) BM_SetHFlag(e, BM_SEAM); + e->head.flag = MEFlags_To_BMFlags(medge, BM_EDGE); } if (!me->totpoly) return; @@ -118,6 +117,9 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) { f = BM_Make_Ngon(bm, v1, v2, fedges, mpoly->totloop, 0); + f->head.flag = MEFlags_To_BMFlags(mpoly, BM_FACE); + if (i == me->act_face) bm->act_face = f; + /*Copy Custom Data*/ CustomData_to_bmesh_block(&me->fdata, &bm->pdata, i, &f->data); } @@ -214,8 +216,7 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { mvert->no[1] = (unsigned char) (v->no[1]*255.0f); mvert->no[2] = (unsigned char) (v->no[2]*255.0f); - if (BM_TestHFlag(v, BM_SELECT)) mvert->flag |= SELECT; - if (BM_TestHFlag(v, BM_HIDDEN)) mvert->flag |= ME_HIDE; + mvert->flag = BMFlags_To_MEFlags(v); BMINDEX_SET(v, i); i++; @@ -233,11 +234,8 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { medge->v1 = BMINDEX_GET(e->v1); medge->v2 = BMINDEX_GET(e->v2); - if (BM_TestHFlag(e, BM_SELECT)) medge->flag |= SELECT; - if (BM_TestHFlag(e, BM_HIDDEN)) medge->flag |= ME_HIDE; - if (BM_TestHFlag(e, BM_SHARP)) medge->flag |= ME_SEAM; - if (BM_TestHFlag(e, BM_SEAM)) medge->flag |= ME_SHARP; - + medge->flag = BMFlags_To_MEFlags(e); + BMINDEX_SET(e, i); i++; medge++; @@ -245,10 +243,8 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i = 0; BM_ITER(f, &iter, bmtess, BM_FACES_OF_MESH, NULL) { - if (BM_TestHFlag(f, BM_SELECT)) mface->flag |= ME_FACE_SEL; - if (BM_TestHFlag(f, BM_HIDDEN)) mface->flag |= ME_HIDE; - if (BM_TestHFlag(f, BM_SMOOTH)) mface->flag |= ME_SMOOTH; mface->mat_nr = f->mat_nr; + mface->flag = BMFlags_To_MEFlags(f); mface->v1 = BMINDEX_GET(f->loopbase->v); mface->v2 = BMINDEX_GET(((BMLoop*)f->loopbase->head.next)->v); @@ -276,22 +272,18 @@ void bmesh_to_mesh_exec(BMesh *bm, BMOperator *op) { i = 0; j = 0; BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) { - if (BM_TestHFlag(f, BM_SELECT)) mpoly->flag |= ME_FACE_SEL; - if (BM_TestHFlag(f, BM_HIDDEN)) mpoly->flag |= ME_HIDE; - if (BM_TestHFlag(f, BM_SMOOTH)) mpoly->flag |= ME_SMOOTH; - mpoly->loopstart = j; mpoly->totloop = f->len; mpoly->mat_nr = f->mat_nr; + mpoly->flag = BMFlags_To_MEFlags(f); - //BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f); - for ( ; l; l=BMIter_Step(&liter)) { + for ( ; l; l=BMIter_Step(&liter), j++, mloop++) { mloop->e = BMINDEX_GET(l->e); mloop->v = BMINDEX_GET(l->v); - mloop++; - j++; } + + if (f == bm->act_face) me->act_face = i; i++; mpoly++; diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 973ff190845..d8a9c3e994f 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -105,7 +105,9 @@ static int subdivide_exec(bContext *C, wmOperator *op) BM_esubdivideflag(obedit, em->bm, 1, 0.0, scene->toolsettings->editbutflag, 1, 0); WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); - + + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + return OPERATOR_FINISHED; } @@ -133,6 +135,8 @@ static int subdivide_multi_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + return OPERATOR_FINISHED; } @@ -163,6 +167,8 @@ static int subdivide_multi_fractal_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + return OPERATOR_FINISHED; } @@ -194,6 +200,8 @@ static int subdivide_smooth_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + return OPERATOR_FINISHED; } @@ -597,6 +605,7 @@ short EDBM_Extrude_vert(Object *obedit, BMEditMesh *em, short flag, float *nor) static int extrude_repeat_mesh(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); BMEditMesh *em = ((Mesh *)obedit->data)->edit_btmesh; RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -633,7 +642,7 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit); -// DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); + DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/bmeshutils.c b/source/blender/editors/mesh/bmeshutils.c index 05ef61ed2b5..86027b28ac2 100644 --- a/source/blender/editors/mesh/bmeshutils.c +++ b/source/blender/editors/mesh/bmeshutils.c @@ -356,13 +356,13 @@ BMFace *EDBM_get_face_for_index(BMEditMesh *tm, int index) /* this replaces the active flag used in uv/face mode */ void EDBM_set_actFace(BMEditMesh *em, BMFace *efa) { - em->act_face = efa; + em->bm->act_face = efa; } BMFace *EDBM_get_actFace(BMEditMesh *em, int sloppy) { - if (em->act_face) { - return em->act_face; + if (em->bm->act_face) { + return em->bm->act_face; } else if (sloppy) { BMFace *efa= NULL; BMEditSelection *ese; |