-> Bevel modifier cleanup
authorGeoffrey Bantle <hairbat@yahoo.com>
Sat, 1 Mar 2008 16:32:23 +0000 (16:32 +0000)
committerGeoffrey Bantle <hairbat@yahoo.com>
Sat, 1 Mar 2008 16:32:23 +0000 (16:32 +0000)
Bevel modifier had several problems. These should be fixed now. The bevel
modifier in editmode cannot have 'apply to cage' checked as the modifier
cannot possibly support mapping. Further, custom data preservation has been
turned off temporarily, but will be added back in soon.

source/blender/blenkernel/intern/BME_conversions.c
source/blender/blenkernel/intern/BME_mesh.c
source/blender/blenkernel/intern/BME_structure.c
source/blender/blenkernel/intern/modifier.c

index db4e39794d64c90052633c3a4c566b7991a22e6b..e34aba2d5d738cd45890f2087b69fe340d31d288 100644 (file)
@@ -69,10 +69,8 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
        int len;
 
        BME_model_begin(bm);
-       /*custom data*/
        
        /*add verts*/
-       CustomData_copy(&em->vdata, &bm->vdata, CD_MASK_EDITMESH, CD_CALLOC, 0);
        eve= em->verts.first;
        while(eve) {
                v1 = BME_MV(bm,eve->co);
@@ -84,14 +82,10 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
                /* link the verts for edge and face construction;
                 * kind of a dangerous thing - remember to cast back to BME_Vert before using! */
                eve->tmp.v = (EditVert*)v1;
-
-               CustomData_em_copy_data(&em->vdata, &bm->vdata, eve->data, &v1->data);
-               
                eve = eve->next;
        }
        
        /*add edges*/
-       CustomData_copy(&em->edata, &bm->edata, CD_MASK_EDITMESH, CD_CALLOC, 0);
        eed= em->edges.first;
        while(eed) {
                v1 = (BME_Vert*)eed->v1->tmp.v;
@@ -104,7 +98,6 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
                if(eed->seam) e->flag |= ME_SEAM;
                if(eed->h & EM_FGON) e->flag |= ME_FGON;
                if(eed->h & 1) e->flag |= ME_HIDE;
-               CustomData_em_copy_data(&em->edata, &bm->edata, eed->data, &e->data);
 
                /* link the edges for face construction;
                 * kind of a dangerous thing - remember to cast back to BME_Edge before using! */
@@ -113,7 +106,6 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
        }
 
        /*add faces.*/
-       CustomData_copy(&em->fdata, &bm->pdata, CD_MASK_EDITMESH, CD_CALLOC, 0);
        efa= em->faces.first;
        while(efa) {
                if(efa->v4) len = 4;
@@ -141,8 +133,6 @@ BME_Mesh *BME_editmesh_to_bmesh(EditMesh *em, BME_Mesh *bm) {
                        if(efa->f & 1) f->flag |= ME_FACE_SEL;
                        else f->flag &= ~ME_FACE_SEL;
                }
-               CustomData_em_copy_data(&em->fdata, &bm->pdata, efa->data, &f->data);
-               
                efa = efa->next;
        }
        BME_model_end(bm);
@@ -171,7 +161,6 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
 
        /* convert to EditMesh */
        /* make editverts */
-       CustomData_copy(&bm->vdata, &em->vdata, CD_MASK_EDITMESH, CD_CALLOC, 0);
        totvert = BLI_countlist(&(bm->verts));
        evlist= (EditVert **)MEM_mallocN(totvert*sizeof(void *),"evlist");
        for (i=0,v1=bm->verts.first;v1;v1=v1->next,i++) {
@@ -185,11 +174,9 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                eve1->f = (unsigned char)v1->flag;
                eve1->h = (unsigned char)v1->h;
                eve1->bweight = v1->bweight;
-               CustomData_em_copy_data(&bm->vdata, &em->vdata, v1->data, &eve1->data);
        }
        
        /* make edges */
-       CustomData_copy(&bm->edata, &em->edata, CD_MASK_EDITMESH, CD_CALLOC, 0);
        for (e=bm->edges.first;e;e=e->next) {
                if(!(findedgelist(evlist[e->v1->tflag1], evlist[e->v2->tflag1]))){
                        eed= addedgelist(evlist[e->v1->tflag1], evlist[e->v2->tflag1], NULL);
@@ -202,12 +189,10 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                        if(e->flag & ME_HIDE) eed->h |= 1;
                        if(G.scene->selectmode==SCE_SELECT_EDGE) 
                                EM_select_edge(eed, eed->f & SELECT);
-                       CustomData_em_copy_data(&bm->edata, &em->edata, e->data, &eed->data);
                }
        }
 
        /* make faces */
-       CustomData_copy(&bm->pdata, &em->fdata, CD_MASK_EDITMESH, CD_CALLOC, 0);
        for (f=bm->polys.first;f;f=f->next) {
                len = BME_cycle_length(f->loopbase);
                if (len==3 || len==4) {
@@ -222,7 +207,6 @@ EditMesh *BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td) {
                        }
 
                        efa = addfacelist(eve1, eve2, eve3, eve4, NULL, NULL);
-                       CustomData_em_copy_data(&bm->pdata, &em->fdata, f->data, &efa->data);
                        efa->mat_nr = (unsigned char)f->mat_nr;
                        efa->flag= f->flag & ~ME_HIDE;
                        if(f->flag & ME_FACE_SEL) {
@@ -266,21 +250,13 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm, BME_Mesh *bm)
 
        vert_array = MEM_mallocN(sizeof(*vert_array)*totvert,"BME_derivedmesh_to_bmesh BME_Vert* array");
 
-       /*custom data*/
-       /* NOTE: I haven't tested whether or not custom data is being copied correctly */
-       CustomData_copy(&dm->vertData, &bm->vdata, CD_MASK_DERIVEDMESH,
-                       CD_CALLOC, 0);
-       CustomData_copy(&dm->edgeData, &bm->edata, CD_MASK_DERIVEDMESH,
-                       CD_CALLOC, 0);
-       CustomData_copy(&dm->faceData, &bm->pdata, CD_MASK_DERIVEDMESH,
-                       CD_CALLOC, 0);
+       BME_model_begin(bm);
        /*add verts*/
        for(i=0,mv = mvert; i < totvert;i++,mv++){
                v1 = BME_MV(bm,mv->co);
                vert_array[i] = v1;
                v1->flag = mv->flag;
                v1->bweight = mv->bweight/255.0f;
-               CustomData_to_em_block(&dm->vertData, &bm->vdata, i, &v1->data);
        }
        /*add edges*/
        for(i=0,me = medge; i < totedge;i++,me++){
@@ -291,7 +267,6 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm, BME_Mesh *bm)
                e->bweight = me->bweight/255.0f;
                e->flag = (unsigned char)me->flag;
                BLI_edgehash_insert(edge_hash,me->v1,me->v2,e);
-               CustomData_to_em_block(&dm->edgeData, &bm->edata, i, &e->data);
        }
        /*add faces.*/
        for(i=0,mf = mface; i < totface;i++,mf++){
@@ -315,9 +290,9 @@ BME_Mesh *BME_derivedmesh_to_bmesh(DerivedMesh *dm, BME_Mesh *bm)
                f = BME_MF(bm,v1,v2,edar,len);
                f->mat_nr = mf->mat_nr;
                f->flag = mf->flag;
-               CustomData_to_em_block(&dm->faceData, &bm->pdata, i, &f->data);
        }
        
+       BME_model_end(bm);
        BLI_edgehash_free(edge_hash, NULL);
        MEM_freeN(vert_array);
        return bm;
@@ -364,21 +339,12 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
        
        /*convert back to mesh*/
        result = CDDM_from_template(dm,totvert,totedge,totface);
-       /*custom data*/
-       /* NOTE: I haven't tested whether or not custom data is being copied correctly */
-       CustomData_merge(&bm->vdata, &result->vertData, CD_MASK_DERIVEDMESH,
-                       CD_CALLOC, totvert);
-       CustomData_merge(&bm->edata, &result->edgeData, CD_MASK_DERIVEDMESH,
-                       CD_CALLOC, totedge);
-       CustomData_merge(&bm->pdata, &result->faceData, CD_MASK_DERIVEDMESH,
-                       CD_CALLOC, totface);
        /*Make Verts*/
        mvert = CDDM_get_verts(result);
        for(i=0,v1=bm->verts.first,mv=mvert;v1;v1=v1->next,i++,mv++){
                VECCOPY(mv->co,v1->co);
                mv->flag = (unsigned char)v1->flag;
                mv->bweight = (char)(255.0*v1->bweight);
-               CustomData_from_em_block(&bm->vdata, &result->vertData, v1->data, i);
        }
        medge = CDDM_get_edges(result);
        i=0;
@@ -396,7 +362,6 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
                        me->crease = (char)(255.0*e->crease);
                        me->bweight = (char)(255.0*e->bweight);
                        me->flag = e->flag;
-                       CustomData_from_em_block(&bm->edata, &result->edgeData, e->data, i);
                        me++;
                        i++;
                }
@@ -421,7 +386,6 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
                                i++;
                                mf->mat_nr = (unsigned char)f->mat_nr;
                                mf->flag = (unsigned char)f->flag;
-                               CustomData_from_em_block(&bm->pdata, &result->faceData, f->data, i);
                        }
                }
        }
index eee094da8910cc887fc7ed3decb617a6635ab94c..dfd86f8af8b73e8ae2b6ce1627d1da5dfc7b57e2 100644 (file)
@@ -111,10 +111,10 @@ void BME_free_mesh(BME_Mesh *bm)
        for(loopref=bm->loops.first;loopref;loopref=loopref->next) BME_delete_loop(bm,loopref->data);
        BLI_freelistN(&(bm->loops));
        
-       CustomData_free(&bm->vdata, 0);
-       CustomData_free(&bm->edata, 0);
-       CustomData_free(&bm->ldata, 0);
-       CustomData_free(&bm->pdata, 0);
+       //CustomData_free(&bm->vdata, 0);
+       //CustomData_free(&bm->edata, 0);
+       //CustomData_free(&bm->ldata, 0);
+       //CustomData_free(&bm->pdata, 0);
        
        MEM_freeN(bm);  
 }
index 17f91c1d0783379c4fc1988009e3128e9da1defb..78afb502572262e6ffaf1f7b89c95081e97dd6b6 100644 (file)
@@ -60,7 +60,7 @@ int BME_verts_in_edge(BME_Vert *v1, BME_Vert *v2, BME_Edge *e){
        return 0;
 }
 
-BME_Vert *BME_edge_getothervert(BME_Edge *e, BME_Vert *v){
+BME_Vert *BME_edge_getothervert(BME_Edge *e, BME_Vert *v){     
        if(e->v1 == v) return e->v2;
        else if(e->v2 == v) return e->v1;
        return NULL;
@@ -96,10 +96,10 @@ BME_Vert *BME_addvertlist(BME_Mesh *bm, BME_Vert *example){
 
        if(example)
                VECCOPY(v->co,example->co);
-       if(example)
-               CustomData_em_copy_data(&bm->vdata, &bm->vdata, example->data, &v->data);
-       else
-               CustomData_em_set_default(&bm->vdata, &v->data);
+       //if(example)
+       //      CustomData_em_copy_data(&bm->vdata, &bm->vdata, example->data, &v->data);
+       //else
+       //      CustomData_em_set_default(&bm->vdata, &v->data);
 
        return v;
 }
@@ -115,10 +115,10 @@ BME_Edge *BME_addedgelist(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Edge *ex
        bm->totedge++;
        BLI_addtail(&(bm->edges), e);
        
-       if(example)
-               CustomData_em_copy_data(&bm->edata, &bm->edata, example->data, &e->data);
-       else
-               CustomData_em_set_default(&bm->edata, &e->data);
+       //if(example)
+       //      CustomData_em_copy_data(&bm->edata, &bm->edata, example->data, &e->data);
+       //else
+       //      CustomData_em_set_default(&bm->edata, &e->data);
 
 
        return e;
@@ -156,10 +156,10 @@ BME_Poly *BME_addpolylist(BME_Mesh *bm, BME_Poly *example){
        bm->nextp++;
        bm->totpoly++;
 
-       if(example)
-               CustomData_em_copy_data(&bm->pdata, &bm->pdata, example->data, &f->data);
-       else
-               CustomData_em_set_default(&bm->pdata, &f->data);
+       //if(example)
+       //      CustomData_em_copy_data(&bm->pdata, &bm->pdata, example->data, &f->data);
+       //else
+       //      CustomData_em_set_default(&bm->pdata, &f->data);
 
 
        return f;
@@ -170,22 +170,22 @@ BME_Poly *BME_addpolylist(BME_Mesh *bm, BME_Poly *example){
 */
 void BME_free_vert(BME_Mesh *bm, BME_Vert *v){
        bm->totvert--;
-       CustomData_em_free_block(&bm->vdata, &v->data);
+       //CustomData_em_free_block(&bm->vdata, &v->data);
        MEM_freeN(v);
 }
 void BME_free_edge(BME_Mesh *bm, BME_Edge *e){
        bm->totedge--;
-       CustomData_em_free_block(&bm->edata, &e->data);
+       //CustomData_em_free_block(&bm->edata, &e->data);
        MEM_freeN(e);
 }
 void BME_free_poly(BME_Mesh *bm, BME_Poly *f){
        bm->totpoly--;
-       CustomData_em_free_block(&bm->pdata, &f->data);
+       //CustomData_em_free_block(&bm->pdata, &f->data);
        MEM_freeN(f);
 }
 void BME_delete_loop(BME_Mesh *bm, BME_Loop *l){
        bm->totloop--;
-       CustomData_em_free_block(&bm->ldata, &l->data);
+       //CustomData_em_free_block(&bm->ldata, &l->data);
        MEM_freeN(l);
 }
 void BME_free_loop(BME_Mesh *bm, BME_Loop *l){
index cc54ced4b4d6a37d907e73114b896680f842023e..4db391ddc95e15bea641483b2b81643c9c224020 100644 (file)
@@ -2746,9 +2746,7 @@ static DerivedMesh *bevelModifier_applyModifier(
 
        bm = BME_make_mesh();
        bm = BME_derivedmesh_to_bmesh(derivedData, bm);
-       BME_model_begin(bm);
        BME_bevel(bm,bmd->value,bmd->res,options,defgrp_index,bmd->bevel_angle,NULL);
-       BME_model_end(bm);
        result = BME_bmesh_to_derivedmesh(bm,derivedData);
        BME_free_mesh(bm);
 
@@ -7042,7 +7040,6 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
                mti = INIT_TYPE(Bevel);
                mti->type = eModifierTypeType_Constructive;
                mti->flags = eModifierTypeFlag_AcceptsMesh
-                            | eModifierTypeFlag_SupportsMapping
                             | eModifierTypeFlag_SupportsEditmode
                             | eModifierTypeFlag_EnableInEditmode;
                mti->initData = bevelModifier_initData;