svn merge ^/trunk/blender -r42116:42139
authorCampbell Barton <ideasman42@gmail.com>
Thu, 24 Nov 2011 20:01:45 +0000 (20:01 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 24 Nov 2011 20:01:45 +0000 (20:01 +0000)
1  2 
release/scripts/startup/bl_ui/properties_data_modifier.py
source/blender/blenkernel/intern/curve.c
source/blender/blenlib/intern/pbvh.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/object/object_add.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_scene.c

index a74e20d8264ffb2f9ad72e70566695f90f180111,5e9f863d22bccb7d113b89cbb3f5abae74797e54..e34fd7f538aa9f267ce033c9025f19119234cc67
@@@ -46,11 -46,7 +46,11 @@@ class DATA_PT_modifiers(ModifierButtons
      # the mt.type enum is (ab)used for a lookup on function names
      # ...to avoid lengthy if statements
      # so each type must have a function here.
 -
 +      
 +    def NGONINTERP(self, layout, ob, md):
 +        split = layout.split()
 +        split.prop(md, "resolution")
 +        
      def ARMATURE(self, layout, ob, md):
          split = layout.split()
  
          layout.separator()
  
          layout.prop(md, "use_normals")
-         
          split = layout.split()
-         
          col = split.column()
          col.prop(md, "use_foam")
          sub = col.row()
          sub.active = md.use_foam
          sub.prop(md, "foam_coverage", text="Coverage")
-         
          col = split.column()
          col.active = md.use_foam
          col.label("Foam Data Layer Name:")
index 5f1a5f739736e721c3b91eaef383abbd2eca25cd,358c63b4f9f819384d02a8847f5c14b124eeabcd..ccafb65312af2055567195f1c3cd77f4aa4c6ac4
@@@ -49,7 -49,6 +49,7 @@@
  #include "DNA_key_types.h"  
  #include "DNA_scene_types.h"  
  #include "DNA_vfont_types.h"  
 +#include "DNA_meshdata_types.h"  
  #include "DNA_object_types.h"
  
  #include "BKE_animsys.h"
@@@ -170,6 -169,7 +170,7 @@@ Curve *add_curve(const char *name, int 
        cu->texflag= CU_AUTOSPACE;
        cu->smallcaps_scale= 0.75f;
        cu->twist_mode= CU_TWIST_MINIMUM;       // XXX: this one seems to be the best one in most cases, at least for curve deform...
+       cu->type= type;
        
        cu->bb= unit_boundbox();
        
@@@ -304,16 -304,23 +305,23 @@@ ListBase *curve_editnurbs(Curve *cu
  short curve_type(Curve *cu)
  {
        Nurb *nu;
+       int type= cu->type;
        if(cu->vfont) {
                return OB_FONT;
        }
-       for (nu= cu->nurb.first; nu; nu= nu->next) {
-               if(nu->pntsv>1) {
-                       return OB_SURF;
+       if(!cu->type) {
+               type= OB_CURVE;
+               for (nu= cu->nurb.first; nu; nu= nu->next) {
+                       if(nu->pntsv>1) {
+                               type= OB_SURF;
+                       }
                }
        }
-       
-       return OB_CURVE;
+       return type;
  }
  
  void update_curve_dimension(Curve *cu)
index ecf8fc706b95dbb96380c59ec7f02ce06a2c066b,5c7a29c6277b62e91837a71b1877b959a5c1563f..ae0becc840b7ce63a48419aa262a7ab6f853782e
@@@ -656,12 -656,17 +656,17 @@@ void BLI_pbvh_free(PBVH *bvh
                        /* if pbvh was deformed, new memory was allocated for verts/faces -- free it */
  
                        MEM_freeN(bvh->verts);
-                       MEM_freeN(bvh->faces);
+                       if(bvh->faces)
+                               MEM_freeN(bvh->faces);
                }
        }
  
-       MEM_freeN(bvh->nodes);
-       MEM_freeN(bvh->prim_indices);
+       if(bvh->nodes)
+               MEM_freeN(bvh->nodes);
+       if(bvh->prim_indices)
+               MEM_freeN(bvh->prim_indices);
        MEM_freeN(bvh);
  }
  
@@@ -1127,6 -1132,9 +1132,9 @@@ void BLI_pbvh_update(PBVH *bvh, int fla
        PBVHNode **nodes;
        int totnode;
  
+       if(!bvh->nodes)
+               return;
        BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag),
                &nodes, &totnode);
  
@@@ -1577,7 -1585,7 +1585,7 @@@ void BLI_pbvh_apply_vertCos(PBVH *pbvh
                }
  
                /* coordinates are new -- normals should also be updated */
 -              mesh_calc_normals(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL);
 +              mesh_calc_tessface_normals(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL);
  
                for (a= 0; a < pbvh->totnode; ++a)
                        BLI_pbvh_node_mark_update(&pbvh->nodes[a]);
index df5429960c3a3c078d8edf9c81be591eb411a209,c5e59959ddd2520b7c66638499a105a53b8d8d31..78efc686da472e793df069a908b4c306807802ba
@@@ -1666,7 -1666,8 +1666,8 @@@ static void write_customdata(WriteData 
                                writestruct(wd, DATA, structname, datasize, layer->data);
                        }
                        else
-                               printf("error: this CustomDataLayer must not be written to file\n");
+                               printf("%s error: layer '%s':%d - can't be written to file\n",
+                                      __func__, structname, layer->type);
                }
        }
  
@@@ -1694,7 -1695,6 +1695,7 @@@ static void write_meshs(WriteData *wd, 
                                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);
                        }
                                write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, -1, 0);
                                write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, -1, 0);
                                write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, -1, 0);
 +                              write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, -1, 0);
 +                              write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, -1, 0);
                        }
  
                        /* PMV data */
index 00c59c48c1c187a755a7feee05b5b9118211eafd,bcd8b8903e77ea2611ae9957624b78d09e057362..b168a9c4cf317aae01faa9beb3b9505ed92493d4
@@@ -244,8 -244,7 +244,8 @@@ int ED_object_add_generic_invoke(bConte
        return op->type->exec(C, op);
  }
  
 -int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, float *rot, int *enter_editmode, unsigned int *layer)
 +int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, 
 +      float *rot, int *enter_editmode, unsigned int *layer, int *is_view_aligned)
  {
        View3D *v3d = CTX_wm_view3d(C);
        int a, layer_values[20];
        else
                RNA_float_get_array(op->ptr, "rotation", rot);
        
 -
 +      if (is_view_aligned)
 +              *is_view_aligned = view_align;
 +      
        RNA_float_get_array(op->ptr, "location", loc);
  
        if(*layer == 0) {
  
  /* for object add primitive operators */
  /* do not call undo push in this function (users of this function have to) */
 -Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer)
 +Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, 
 +      int enter_editmode, unsigned int layer)
  {
        Main *bmain= CTX_data_main(C);
        Scene *scene= CTX_data_scene(C);
@@@ -347,7 -343,7 +347,7 @@@ static int object_add_exec(bContext *C
        unsigned int layer;
        float loc[3], rot[3];
        
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
  
        ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), loc, rot, enter_editmode, layer);
@@@ -404,7 -400,7 +404,7 @@@ static Object *effector_add_type(bConte
        
        object_add_generic_invoke_options(C, op);
  
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return NULL;
  
        if(type==PFIELD_GUIDE) {
@@@ -484,7 -480,7 +484,7 @@@ static int object_camera_add_exec(bCont
        
        object_add_generic_invoke_options(C, op);
  
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
  
        ob= ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE, layer);
@@@ -538,7 -534,7 +538,7 @@@ static int object_metaball_add_exec(bCo
        
        object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
  
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
        
        if(obedit==NULL || obedit->type!=OB_MBALL) {
@@@ -607,7 -603,7 +607,7 @@@ static int object_add_text_exec(bContex
        float loc[3], rot[3];
        
        object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
        
        if(obedit && obedit->type==OB_FONT)
@@@ -648,7 -644,7 +648,7 @@@ static int object_armature_add_exec(bCo
        float loc[3], rot[3];
        
        object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
        
        if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) {
@@@ -716,7 -712,7 +716,7 @@@ static int object_lamp_add_exec(bContex
        float loc[3], rot[3];
        
        object_add_generic_invoke_options(C, op);
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
  
        ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer);
@@@ -772,7 -768,7 +772,7 @@@ static int group_instance_add_exec(bCon
        float loc[3], rot[3];
        
        object_add_generic_invoke_options(C, op);
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
  
        if(group) {
@@@ -804,7 -800,7 +804,7 @@@ static int object_speaker_add_exec(bCon
        Scene *scene = CTX_data_scene(C);
  
        object_add_generic_invoke_options(C, op);
 -      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 +      if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL))
                return OPERATOR_CANCELLED;
  
        ob= ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer);
@@@ -1343,11 -1339,7 +1343,11 @@@ static int convert_exec(bContext *C, wm
                        dm= mesh_get_derived_final(scene, newob, CD_MASK_MESH);
                        /* dm= mesh_create_derived_no_deform(ob1, NULL);        this was called original (instead of get_derived). man o man why! (ton) */
  
 -                      DM_to_mesh(dm, newob->data);
 +                      DM_to_mesh(dm, newob->data, newob);
 +
 +                      /* re-tesselation doesn't happen automatic, calling like this is  */
 +                      me= newob->data;
 +                      me->totface = mesh_recalcTesselation(&me->fdata, &me->ldata, &me->pdata, me->mvert, me->totface, me->totloop, me->totpoly);
  
                        dm->release(dm);
                        object_free_modifiers(newob);   /* after derivedmesh calls! */
                                makeDispListCurveTypes(scene, newob, 0);
  
                        newob->type= OB_CURVE;
+                       cu->type= OB_CURVE;
  
                        if(cu->vfont) {
                                cu->vfont->id.us--;
index c4412d3d8f2f3c6b83099aad15c01218879f79ee,15494d73ea17be6745f4eb36e5439d3661266172..1f49a4d526beaac5c401269d03f146eaa9408531
@@@ -58,7 -58,6 +58,7 @@@
  #include "BKE_main.h"
  #include "BKE_mesh.h"
  #include "BKE_screen.h"
 +#include "BKE_tessmesh.h"
  #include "BKE_deform.h"
  
  #include "WM_api.h"
@@@ -153,36 -152,32 +153,36 @@@ static void v3d_editvertex_buts(uiLayou
        
        if(ob->type==OB_MESH) {
                Mesh *me= ob->data;
 -              EditMesh *em = BKE_mesh_get_editmesh(me);
 -              EditVert *eve, *evedef=NULL;
 -              EditEdge *eed;
 +              BMEditMesh *em = me->edit_btmesh;
 +              BMesh *bm = em->bm;
 +              BMVert *eve, *evedef=NULL;
 +              BMEdge *eed;
 +              BMIter iter;
                
 -              eve= em->verts.first;
 -              while(eve) {
 -                      if(eve->f & SELECT) {
 +              BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) {
 +                      if(BM_TestHFlag(eve, BM_SELECT)) {
                                evedef= eve;
                                tot++;
                                add_v3_v3(median, eve->co);
                        }
 -                      eve= eve->next;
                }
 -              eed= em->edges.first;
 -              while(eed) {
 -                      if((eed->f & SELECT)) {
 +
 +              BM_ITER(eed, &iter, bm, BM_EDGES_OF_MESH, NULL) {
 +                      if(BM_TestHFlag(eed, BM_SELECT)) {
 +                              float *f;
 +
                                totedge++;
 -                              median[3]+= eed->crease;
 -                              median[6]+= eed->bweight;
 +                              f = bm_get_cd_float(&bm->edata, eed->head.data, CD_CREASE);
 +                              median[3]+= f ? *f : 0.0f;
 +
 +                              f = bm_get_cd_float(&bm->edata, eed->head.data, CD_BWEIGHT);
 +                              median[6]+= f ? *f : 0.0f;
                        }
 -                      eed= eed->next;
                }
  
                /* check for defgroups */
                if(evedef)
 -                      dvert= CustomData_em_get(&em->vdata, evedef->data, CD_MDEFORMVERT);
 +                      dvert= CustomData_bmesh_get(&em->bm->vdata, evedef->head.data, CD_MDEFORMVERT);
                if(tot==1 && dvert && dvert->totweight) {
                        bDeformGroup *dg;
                        int i, max=1, init=1;
                                tfp->defweightp= &dvert->dw[0].weight;
                        }
                }
 -
 -              BKE_mesh_end_editmesh(me, em);
        }
        else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
                Curve *cu= ob->data;
                
                if(ob->type==OB_MESH) {
                        Mesh *me= ob->data;
 -                      EditMesh *em = BKE_mesh_get_editmesh(me);
 +                      BMEditMesh *em = me->edit_btmesh;
 +                      BMVert *eve;
 +                      BMIter iter;
  
 -                      /* allow for some rounding error becasue of matrix transform */
                        if(len_v3(median) > 0.000001f) {
 -                              EditVert *eve;
  
 -                              for(eve= em->verts.first; eve; eve= eve->next) {
 -                                      if(eve->f & SELECT) {
 +                              BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                                      if(BM_TestHFlag(eve, BM_SELECT)) {
                                                add_v3_v3(eve->co, median);
                                        }
                                }
 -
 -                              recalc_editnormals(em);
 +                              
 +                              EDBM_RecalcNormals(em);
                        }
 -
 +                      
                        if(median[3] != 0.0f) {
 -                              EditEdge *eed;
 +                              BMEdge *eed;
                                const float fixed_crease= (ve_median[3] <= 0.0f ? 0.0f : (ve_median[3] >= 1.0f ? 1.0f : FLT_MAX));
 -
 +                              
                                if(fixed_crease != FLT_MAX) {
                                        /* simple case */
  
 -                                      for(eed= em->edges.first; eed; eed= eed->next) {
 -                                              if(eed->f & SELECT) {
 -                                                      eed->crease= fixed_crease;
 +                                      BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                                              if(BM_TestHFlag(eed, BM_SELECT)) {
 +                                                      float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE);
 +                                                      if (!crease) break;
 +                                                      
 +                                                      *crease= fixed_crease;
                                                }
                                        }
                                }
                                                /* scale down */
                                                const float sca= median_new / median_orig;
                                                
 -                                              for(eed= em->edges.first; eed; eed= eed->next) {
 -                                                      if(eed->f & SELECT) {
 -                                                              eed->crease *= sca;
 -                                                              CLAMP(eed->crease, 0.0f, 1.0f);
 +                                              BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                                                      if(BM_TestHFlag(eed, BM_SELECT) && !BM_TestHFlag(eed, BM_HIDDEN)) {
 +                                                              float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE);
 +                                                              
 +                                                              if (!crease) break;
 +                                                              
 +                                                              *crease *= sca;
 +                                                              CLAMP(*crease, 0.0f, 1.0f);
                                                        }
                                                }
                                        }
                                                /* scale up */
                                                const float sca= (1.0f - median_new) / (1.0f - median_orig);
  
 -                                              for(eed= em->edges.first; eed; eed= eed->next) {
 -                                                      if(eed->f & SELECT) {
 -                                                              eed->crease = 1.0f - ((1.0f - eed->crease) * sca);
 -                                                              CLAMP(eed->crease, 0.0f, 1.0f);
 +                                              BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                                                      if(BM_TestHFlag(eed, BM_SELECT) && !BM_TestHFlag(eed, BM_HIDDEN)) {
 +                                                              float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE);
 +                                                              if (!crease) break;
 +
 +                                                              *crease = 1.0f - ((1.0f - *crease) * sca);
 +                                                              CLAMP(*crease, 0.0f, 1.0f);
                                                        }
                                                }
                                        }
                                }
                        }
 -
                        if (median[6] != 0.0f) {
 +#if 0 // BMESH_TODO
                                EditEdge *eed;
                                const float fixed_bweight= (ve_median[6] <= 0.0f ? 0.0f : (ve_median[6] >= 1.0f ? 1.0f : FLT_MAX));
  
                                                }
                                        }
                                }
 +#endif // BMESH_TODO
                        }
 -                      BKE_mesh_end_editmesh(me, em);
 +                      EDBM_RecalcNormals(em);
                }
                else if(ob->type==OB_CURVE || ob->type==OB_SURF) {
                        Curve *cu= ob->data;
  #define B_VGRP_PNL_EDIT_SINGLE 8 /* or greater */
  #define B_VGRP_PNL_COPY_SINGLE 16384 /* or greater */
  
 -static void act_vert_def(Object *ob, EditVert **eve, MDeformVert **dvert)
 +static void act_vert_def(Object *ob, BMVert **eve, MDeformVert **dvert)
  {
        if(ob && ob->mode & OB_MODE_EDIT && ob->type==OB_MESH && ob->defbase.first) {
                Mesh *me= ob->data;
 -              EditMesh *em = BKE_mesh_get_editmesh(me);
 -              EditSelection *ese = ((EditSelection*)em->selected.last);
 +              BMEditMesh *em = me->edit_btmesh;
 +              BMEditSelection *ese= (BMEditSelection*)em->bm->selected.last;
  
 -              if(ese && ese->type == EDITVERT) {
 -                      *eve= (EditVert*)ese->data;
 -                      *dvert= CustomData_em_get(&em->vdata, (*eve)->data, CD_MDEFORMVERT);
 +              if(ese && ese->htype == BM_VERT) {
 +                      *eve= (BMVert*)ese->data;
 +                      *dvert= CustomData_bmesh_get(&em->bm->vdata, (*eve)->head.data, CD_MDEFORMVERT);
                        return;
                }
 -
 -              BKE_mesh_end_editmesh(me, em);
        }
  
        *eve= NULL;
        *dvert= NULL;
  }
  
 -static void editvert_mirror_update(Object *ob, EditVert *eve, int def_nr, int index)
 +static void editvert_mirror_update(Object *ob, BMVert *eve, int def_nr, int index)
  {
        Mesh *me= ob->data;
 -      EditMesh *em = BKE_mesh_get_editmesh(me);
 -      EditVert *eve_mirr;
 +      BMEditMesh *em = me->edit_btmesh;
 +      BMVert *eve_mirr;
  
 -      eve_mirr= editmesh_get_x_mirror_vert(ob, em, eve, eve->co, index);
 +      eve_mirr= editbmesh_get_x_mirror_vert(ob, em, eve, eve->co, index);
  
        if(eve_mirr && eve_mirr != eve) {
 -              MDeformVert *dvert_src= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 -              MDeformVert *dvert_dst= CustomData_em_get(&em->vdata, eve_mirr->data, CD_MDEFORMVERT);
 +              MDeformVert *dvert_src= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
 +              MDeformVert *dvert_dst= CustomData_bmesh_get(&em->bm->vdata, eve_mirr->head.data, CD_MDEFORMVERT);
                if(dvert_dst) {
                        if(def_nr == -1) {
                                /* all vgroups, add groups where neded  */
  
  static void vgroup_adjust_active(Object *ob, int def_nr)
  {
 -      EditVert *eve_act;
 +      BMVert *eve_act;
        MDeformVert *dvert_act;
  
        act_vert_def(ob, &eve_act, &dvert_act);
  
  static void vgroup_copy_active_to_sel(Object *ob)
  {
 -      EditVert *eve_act;
 +      BMVert *eve_act;
        MDeformVert *dvert_act;
  
        act_vert_def(ob, &eve_act, &dvert_act);
        }
        else {
                Mesh *me= ob->data;
 -              EditMesh *em = BKE_mesh_get_editmesh(me);
 -              EditVert *eve;
 +              BMEditMesh *em = me->edit_btmesh;
 +              BMIter iter;
 +              BMVert *eve;
                MDeformVert *dvert;
                int index= 0;
  
 -              for(eve= em->verts.first; eve; eve= eve->next, index++) {
 -                      if(eve->f & SELECT && eve != eve_act) {
 -                              dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +              BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                      if(BM_TestHFlag(eve, BM_SELECT) && eve != eve_act) {
 +                              dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
                                if(dvert) {
                                        defvert_copy(dvert, dvert_act);
  
  
                                }
                        }
 +
 +                      index++;
                }
        }
  }
  
  static void vgroup_copy_active_to_sel_single(Object *ob, int def_nr)
  {
 -      EditVert *eve_act;
 +      BMVert *eve_act;
        MDeformVert *dvert_act;
  
        act_vert_def(ob, &eve_act, &dvert_act);
        }
        else {
                Mesh *me= ob->data;
 -              EditMesh *em = BKE_mesh_get_editmesh(me);
 -              EditVert *eve;
 +              BMEditMesh *em = me->edit_btmesh;
 +              BMIter iter;
 +              BMVert *eve;
                MDeformVert *dvert;
                MDeformWeight *dw;
                float act_weight = -1.0f;
  
                if(act_weight < -0.5f)
                        return;
 -
 -              for(eve= em->verts.first; eve; eve= eve->next, index++) {
 -                      if(eve->f & SELECT && eve != eve_act) {
 -                              dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +              
 +              eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
 +              for (index=0; eve; eve=BMIter_Step(&iter), index++) {
 +                      if(BM_TestHFlag(eve, BM_SELECT) && eve != eve_act) {
 +                              dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
                                if(dvert) {
                                        for(i=0, dw=dvert->dw; i < dvert->totweight; i++, dw++) {
                                                if(def_nr == dw->def_nr) {
  
  static void vgroup_normalize_active(Object *ob)
  {
 -      EditVert *eve_act;
 +      BMVert *eve_act;
        MDeformVert *dvert_act;
  
        act_vert_def(ob, &eve_act, &dvert_act);
@@@ -809,7 -792,7 +809,7 @@@ static int view3d_panel_vgroup_poll(con
  {
        Scene *scene= CTX_data_scene(C);
        Object *ob= OBACT;
 -      EditVert *eve_act;
 +      BMVert *eve_act;
        MDeformVert *dvert_act;
  
        act_vert_def(ob, &eve_act, &dvert_act);
@@@ -824,7 -807,7 +824,7 @@@ static void view3d_panel_vgroup(const b
        Scene *scene= CTX_data_scene(C);
        Object *ob= OBACT;
  
 -      EditVert *eve;
 +      BMVert *eve;
        MDeformVert *dvert;
  
        act_vert_def(ob, &eve, &dvert);
@@@ -1382,142 -1365,6 +1382,6 @@@ static void view3d_panel_preview(bConte
  }
  #endif
  
- #if 0 // XXX not used
- static void delete_sketch_armature(bContext *C, void *arg1, void *arg2)
- {
-       BIF_deleteSketch(C);
- }
- static void convert_sketch_armature(bContext *C, void *arg1, void *arg2)
- {
-       BIF_convertSketch(C);
- }
- static void assign_template_sketch_armature(bContext *C, void *arg1, void *arg2)
- {
-       int index = *(int*)arg1;
-       BIF_setTemplate(C, index);
- }
- static int view3d_panel_bonesketch_spaces_poll(const bContext *C, PanelType *pt)
- {
-       Object *obedit = CTX_data_edit_object(C);
-       /* replace with check call to sketching lib */
-       return (obedit && obedit->type == OB_ARMATURE);
- }
- static void view3d_panel_bonesketch_spaces(const bContext *C, Panel *pa)
- {
-       Scene *scene = CTX_data_scene(C);
-       static int template_index;
-       static char joint_label[128];
-       uiBlock *block;
-       uiBut *but;
-       char *bone_name;
-       int yco = 130;
-       int nb_joints;
-       static char subdiv_tooltip[4][64] = {
-               "Subdivide arcs based on a fixed number of bones",
-               "Subdivide arcs in bones of equal length",
-               "Subdivide arcs based on correlation",
-               "Retarget template to stroke"
-               };
-       
-       block= uiLayoutAbsoluteBlock(pa->layout);
-       uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
-       uiBlockBeginAlign(block);
-       
-       /* use real flag instead of 1 */
-       uiDefButBitC(block, TOG, BONE_SKETCHING, B_REDR, "Use Bone Sketching", 10, yco, 160, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Use sketching to create and edit bones, (Ctrl snaps to mesh volume)");
-       uiDefButBitC(block, TOG, BONE_SKETCHING_ADJUST, B_REDR, "A", 170, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Adjust strokes by drawing near them");
-       uiDefButBitC(block, TOG, BONE_SKETCHING_QUICK, B_REDR, "Q", 190, yco, 20, 20, &scene->toolsettings->bone_sketching, 0, 0, 0, 0, "Automatically convert and delete on stroke end");
-       yco -= 20;
-       
-       but = uiDefBut(block, BUT, B_REDR, "Convert", 10,yco,100,20, 0, 0, 0, 0, 0, "Convert sketch to armature");
-       uiButSetFunc(but, convert_sketch_armature, NULL, NULL);
-       but = uiDefBut(block, BUT, B_REDR, "Delete", 110,yco,100,20, 0, 0, 0, 0, 0, "Delete sketch");
-       uiButSetFunc(but, delete_sketch_armature, NULL, NULL);
-       yco -= 20;
-       
-       uiBlockEndAlign(block);
-       uiBlockBeginAlign(block);
-       
-       uiDefButC(block, MENU, B_REDR, "Subdivision Method%t|Length%x1|Adaptative%x2|Fixed%x0|Template%x3", 10,yco,60,19, &scene->toolsettings->bone_sketching_convert, 0, 0, 0, 0, subdiv_tooltip[(unsigned char)scene->toolsettings->bone_sketching_convert]);
-       switch(scene->toolsettings->bone_sketching_convert)
-       {
-       case SK_CONVERT_CUT_LENGTH:
-               uiDefButF(block, NUM, B_REDR,                                   "Lim:",         70, yco, 140, 19, &scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0,             "Maximum length of the subdivided bones");
-               yco -= 20;
-               break;
-       case SK_CONVERT_CUT_ADAPTATIVE:
-               uiDefButF(block, NUM, B_REDR,                                   "Thres:",                       70, yco, 140, 19, &scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0,      "Correlation threshold for subdivision");
-               yco -= 20;
-               break;
-       default:
-       case SK_CONVERT_CUT_FIXED:
-               uiDefButC(block, NUM, B_REDR,                                   "Num:",         70, yco, 140, 19, &scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5,  "Number of subdivided bones");
-               yco -= 20;
-               break;
-       case SK_CONVERT_RETARGET:
-               uiDefButC(block, ROW, B_NOP, "No",                      70,  yco, 40,19, &scene->toolsettings->skgen_retarget_roll, 0, 0, 0, 0,                                                                 "No special roll treatment");
-               uiDefButC(block, ROW, B_NOP, "View",            110,  yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_VIEW, 0, 0,                            "Roll bones perpendicular to view");
-               uiDefButC(block, ROW, B_NOP, "Joint",           160, yco, 50,19, &scene->toolsettings->skgen_retarget_roll, 0, SK_RETARGET_ROLL_JOINT, 0, 0,                            "Roll bones relative to joint bend");
-               yco -= 30;
-               uiBlockEndAlign(block);
-               uiBlockBeginAlign(block);
-               /* button here to select what to do (copy or not), template, ...*/
-               BIF_makeListTemplates(C);
-               template_index = BIF_currentTemplate(C);
-               
-               but = uiDefButI(block, MENU, B_REDR, BIF_listTemplates(C), 10,yco,200,19, &template_index, 0, 0, 0, 0, "Template");
-               uiButSetFunc(but, assign_template_sketch_armature, &template_index, NULL);
-               
-               yco -= 20;
-               
-               uiDefButF(block, NUM, B_NOP,                                                    "A:",                   10, yco, 66,19, &scene->toolsettings->skgen_retarget_angle_weight, 0, 10, 1, 0,         "Angle Weight");
-               uiDefButF(block, NUM, B_NOP,                                                    "L:",                   76, yco, 67,19, &scene->toolsettings->skgen_retarget_length_weight, 0, 10, 1, 0,                "Length Weight");
-               uiDefButF(block, NUM, B_NOP,                                                    "D:",           143,yco, 67,19, &scene->toolsettings->skgen_retarget_distance_weight, 0, 10, 1, 0,              "Distance Weight");
-               yco -= 20;
-               
-               uiDefBut(block, TEX,B_REDR,"S:",                                                        10,  yco, 90, 20, scene->toolsettings->skgen_side_string, 0.0, 8.0, 0, 0, "Text to replace &S with");
-               uiDefBut(block, TEX,B_REDR,"N:",                                                        100, yco, 90, 20, scene->toolsettings->skgen_num_string, 0.0, 8.0, 0, 0, "Text to replace &N with");
-               uiDefIconButBitC(block, TOG, SK_RETARGET_AUTONAME, B_NOP, ICON_AUTO,190,yco,20,20, &scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0, "Use Auto Naming");        
-               yco -= 20;
-               /* auto renaming magic */
-               uiBlockEndAlign(block);
-               
-               nb_joints = BIF_nbJointsTemplate(C);
-               if (nb_joints == -1)
-               {
-                       //XXX
-                       //nb_joints = G.totvertsel;
-               }
-               
-               bone_name = BIF_nameBoneTemplate(C);
-               
-               BLI_snprintf(joint_label, 32, "%i joints: %s", nb_joints, bone_name);
-               
-               uiDefBut(block, LABEL, 1, joint_label,                                  10, yco, 200, 20, NULL, 0.0, 0.0, 0, 0, "");
-               yco -= 20;
-               break;
-       }
-       uiBlockEndAlign(block);
- }
- #endif // XXX not used
  void view3d_buttons_register(ARegionType *art)
  {
        PanelType *pt;
index a25ed938c0f3dc46f26150e319e6e1caa0ec03a3,6c359f2c040e1fa003b2378bad05b34a5b744ca9..198a66499aeb712b286d6d45c0d3ee73ed6caee9
@@@ -112,8 -112,9 +112,9 @@@ typedef struct uiStyle 
        short buttonspacex;
        short buttonspacey;
        short panelspace;
+       short panelouter;
  
-       short pad[2];
+       short pad;
  } uiStyle;
  
  typedef struct uiWidgetColors {
@@@ -407,7 -408,7 +408,7 @@@ typedef struct UserDef 
        struct ColorBand coba_weight;   /* from texture.h */
  
        float sculpt_paint_overlay_col[3];
 -      int pad3;
 +      int loopcut_finish_on_release;
  
        char author[80];        /* author name for file formats supporting it */
  } UserDef;
index 947e4d53d8b8cd394d7fca642bb73549193d94a3,8661c0f1ae951d2801abcade1240495528ce8fd7..1ee24a508b633b0a148df5046125be9befbe62ee
@@@ -39,8 -39,6 +39,8 @@@
  #include "DNA_userdef_types.h"
  #include "BLI_math.h"
  
 +#include "BKE_tessmesh.h"
 +
  /* Include for Bake Options */
  #include "RE_engine.h"
  #include "RE_pipeline.h"
@@@ -1072,9 -1070,9 +1072,9 @@@ static void rna_Scene_editmesh_select_m
  
                if(scene->basact) {
                        Mesh *me= get_mesh(scene->basact->object);
 -                      if(me && me->edit_mesh && me->edit_mesh->selectmode != flag) {
 -                              me->edit_mesh->selectmode= flag;
 -                              EM_selectmode_set(me->edit_mesh);
 +                      if(me && me->edit_btmesh && me->edit_btmesh->selectmode != flag) {
 +                              me->edit_btmesh->selectmode= flag;
 +                              EDBM_selectmode_set(me->edit_btmesh);
                        }
                }
        }
@@@ -1086,7 -1084,7 +1086,7 @@@ static void rna_Scene_editmesh_select_m
  
        if(scene->basact) {
                me= get_mesh(scene->basact->object);
 -              if(me && me->edit_mesh==NULL)
 +              if(me && me->edit_btmesh==NULL)
                        me= NULL;
        }
  
@@@ -2790,27 -2788,6 +2790,6 @@@ static void rna_def_scene_render_data(B
        RNA_def_property_range(prop, 1.0f, 200.0f);
        RNA_def_property_ui_text(prop, "Pixel Aspect Y", "Vertical aspect ratio - for anamorphic or non-square pixel output");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update");
-       
-       /* JPEG and AVI JPEG */
- #if 0 /* moved */
-       prop= RNA_def_property(srna, "file_quality", PROP_INT, PROP_PERCENTAGE);
-       RNA_def_property_int_sdna(prop, NULL, "quality");
-       RNA_def_property_range(prop, 0, 100); /* 0 is needed for compression. */
-       RNA_def_property_ui_text(prop, "Quality", "Quality of JPEG images, AVI Jpeg and SGI movies, compression for PNG's");
-       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
- #endif
-       /* Tiff */
-       
- #if 0 /* replaced, use generic */
-       prop= def_property(srna, "use_tiff_16bit", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "subimtype", R_TIFF_16BIT);
-       RNA_def_property_ui_text(prop, "16 Bit", "Save TIFF with 16 bits per channel");
-       RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
- #endif
  
  #ifdef WITH_QUICKTIME
        /* QuickTime */