svn merge ^/trunk/blender -r43085:43092
authorCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jan 2012 07:33:11 +0000 (07:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 3 Jan 2012 07:33:11 +0000 (07:33 +0000)
1  2 
source/blender/editors/object/object_vgroup.c
source/blender/modifiers/SConscript

index 7a5fe38865b0803c4e306074fb04e947b2deebaf,dfe0b94605daba0975dab0c72b9d28c300bb6a50..c5afc740c24760127c0e76752a3beca63dc6329e
@@@ -41,7 -41,6 +41,7 @@@
  #include "DNA_curve_types.h"
  #include "DNA_lattice_types.h"
  #include "DNA_meshdata_types.h"
 +#include "DNA_mesh_types.h"
  #include "DNA_modifier_types.h"
  #include "DNA_object_types.h"
  #include "DNA_object_force.h"
@@@ -50,7 -49,7 +50,7 @@@
  
  #include "BLI_math.h"
  #include "BLI_blenlib.h"
 -#include "BLI_editVert.h"
 +#include "BLI_cellalloc.h"
  #include "BLI_utildefines.h"
  
  #include "BKE_context.h"
@@@ -59,7 -58,6 +59,7 @@@
  #include "BKE_depsgraph.h"
  #include "BKE_global.h"
  #include "BKE_mesh.h"
 +#include "BKE_tessmesh.h"
  #include "BKE_report.h"
  #include "BKE_DerivedMesh.h"
  
@@@ -92,7 -90,7 +92,7 @@@ static Lattice *vgroup_edit_lattice(Obj
  int ED_vgroup_object_is_edit_mode(Object *ob)
  {
        if(ob->type == OB_MESH)
 -              return (((Mesh*)ob->data)->edit_mesh != NULL);
 +              return (((Mesh*)ob->data)->edit_btmesh != NULL);
        else if(ob->type == OB_LATTICE)
                return (((Lattice*)ob->data)->editlatt != NULL);
  
@@@ -189,33 -187,31 +189,33 @@@ static int ED_vgroup_give_parray(ID *id
                        {
                                Mesh *me = (Mesh *)id;
  
 -                              if(me->edit_mesh) {
 -                                      EditMesh *em = me->edit_mesh;
 -                                      EditVert *eve;
 +                              if(me->edit_btmesh) {
 +                                      BMEditMesh *em = me->edit_btmesh;
 +                                      BMIter iter;
 +                                      BMVert *eve;
                                        int i;
  
 -                                      if (!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) {
 +                                      if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
                                                return 0;
                                        }
  
 -                                      i= BLI_countlist(&em->verts);
 +                                      i = em->bm->totvert;
  
                                        *dvert_arr= MEM_mallocN(sizeof(void*)*i, "vgroup parray from me");
                                        *dvert_tot = i;
  
                                        i = 0;
 -
                                        if (use_vert_sel) {
 -                                              for (eve=em->verts.first; eve; eve=eve->next, i++) {
 -                                                      (*dvert_arr)[i] = (eve->f & SELECT) ?
 -                                                                                         CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT) : NULL;
 +                                              BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                                                      (*dvert_arr)[i] = BM_TestHFlag(eve, BM_SELECT) ?
 +                                                                        CustomData_em_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT) : NULL;
 +                                                      i++;
                                                }
                                        }
                                        else {
 -                                              for (eve=em->verts.first; eve; eve=eve->next, i++) {
 -                                                      (*dvert_arr)[i] = CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +                                              BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                                                      (*dvert_arr)[i] = CustomData_em_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
 +                                                      i++;
                                                }
                                        }
  
@@@ -362,12 -358,12 +362,12 @@@ int ED_vgroup_copy_array(Object *ob, Ob
  
        for(i=0; i<dvert_tot; i++, dvf++, dv++) {
                if((*dv)->dw)
 -                      MEM_freeN((*dv)->dw);
 +                      BLI_cellalloc_free((*dv)->dw);
  
                *(*dv)= *(*dvf);
  
                if((*dv)->dw)
 -                      (*dv)->dw= MEM_dupallocN((*dv)->dw);
 +                      (*dv)->dw= BLI_cellalloc_dupalloc((*dv)->dw);
        }
  
        MEM_freeN(dvert_array);
@@@ -515,19 -511,19 +515,19 @@@ void ED_vgroup_vert_remove(Object *ob, 
  static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum)
  {
        MDeformVert *dv= NULL;
 -      EditVert *eve;
 +      BMVert *eve;
        Mesh *me;
  
        /* get the deform vertices corresponding to the vertnum */
        if(ob->type==OB_MESH) {
                me= ob->data;
  
 -              if(me->edit_mesh) {
 -                      eve= BLI_findlink(&me->edit_mesh->verts, vertnum);
 +              if(me->edit_btmesh) {
 +                      eve= BM_Vert_AtIndex(me->edit_btmesh->bm, vertnum);
                        if(!eve) {
                                return 0.0f;
                        }
 -                      dv= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT);
 +                      dv= CustomData_bmesh_get(&me->edit_btmesh->bm->vdata, eve->head.data, CD_MDEFORMVERT);
                }
                else {
                        if(vertnum >= me->totvert) {
@@@ -588,23 -584,24 +588,23 @@@ static void vgroup_select_verts(Object 
        if(ob->type == OB_MESH) {
                Mesh *me= ob->data;
  
 -              if (me->edit_mesh) {
 -                      EditMesh *em = BKE_mesh_get_editmesh(me);
 -                      EditVert *eve;
 +              if (me->edit_btmesh) {
 +                      BMEditMesh *em = me->edit_btmesh;
 +                      BMIter iter;
 +                      BMVert *eve;
  
 -                      for (eve=em->verts.first; eve; eve=eve->next) {
 -                              if (!eve->h) {
 -                                      dv= 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_HIDDEN)) {
 +                                      dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
                                        if (defvert_find_index(dv, def_nr)) {
 -                                              if (select)  eve->f |=  SELECT;
 -                                              else         eve->f &= ~SELECT;
 +                                              BM_Select(em->bm, eve, select);
                                        }
                                }
                        }
 -                      /* this has to be called, because this function operates on vertices only */
 -                      if(select) EM_select_flush(em); // vertices to edges/faces
 -                      else EM_deselect_flush(em);
  
 -                      BKE_mesh_end_editmesh(me, em);
 +                      /* this has to be called, because this function operates on vertices only */
 +                      if(select) EDBM_selectmode_flush(em);   // vertices to edges/faces
 +                      else EDBM_deselect_flush(em);
                }
                else {
                        if (me->dvert) {
                                dv = me->dvert;
  
                                for (i=0; i<me->totvert; i++, mv++, dv++) {
-                                       if (defvert_find_index(dv, def_nr)) {
-                                               if (select)  mv->flag |=  SELECT;
-                                               else         mv->flag &= ~SELECT;
+                                       if (!(mv->flag & ME_HIDE)) {
+                                               if (defvert_find_index(dv, def_nr)) {
+                                                       if (select)  mv->flag |=  SELECT;
+                                                       else         mv->flag &= ~SELECT;
+                                               }
                                        }
                                }
  
@@@ -1285,51 -1284,51 +1287,51 @@@ static void vgroup_blend(Object *ob
        int i, dvert_tot=0;
        const int def_nr= ob->actdef-1;
  
 -      EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)ob->data));
 +      BMEditMesh *em= ((Mesh *)ob->data)->edit_btmesh;
        // ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot);
  
        if (em==NULL)
                return;
  
        if (BLI_findlink(&ob->defbase, def_nr)) {
 -              int sel1, sel2;
 +              BMEdge *eed;
 +              BMVert *eve;
 +              BMIter iter;
 +
                int i1, i2;
  
 -              EditEdge *eed;
 -              EditVert *eve;
                float *vg_weights;
                float *vg_users;
 +              int sel1, sel2;
  
 -              i= 0;
 -              for(eve= em->verts.first; eve; eve= eve->next)
 -                      eve->tmp.l= i++;
 +              BM_ElemIndex_Ensure(em->bm, BM_VERT);
  
 -              dvert_tot= i;
 +              dvert_tot= em->bm->totvert;
  
                vg_weights= MEM_callocN(sizeof(float)*dvert_tot, "vgroup_blend_f");
                vg_users= MEM_callocN(sizeof(int)*dvert_tot, "vgroup_blend_i");
  
 -              for(eed= em->edges.first; eed; eed= eed->next) {
 -                      sel1= eed->v1->f & SELECT;
 -                      sel2= eed->v2->f & SELECT;
 +              BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                      sel1= BM_TestHFlag(eed->v1, BM_SELECT);
 +                      sel2= BM_TestHFlag(eed->v2, BM_SELECT);
  
                        if(sel1 != sel2) {
                                /* i1 is always the selected one */
                                if(sel1==TRUE && sel2==FALSE) {
 -                                      i1= eed->v1->tmp.l;
 -                                      i2= eed->v2->tmp.l;
 +                                      i1= BM_GetIndex(eed->v1);
 +                                      i2= BM_GetIndex(eed->v2);
                                        eve= eed->v2;
                                }
                                else {
 -                                      i2= eed->v1->tmp.l;
 -                                      i1= eed->v2->tmp.l;
 +                                      i2= BM_GetIndex(eed->v1);
 +                                      i1= BM_GetIndex(eed->v2);
                                        eve= eed->v1;
                                }
  
                                vg_users[i1]++;
  
                                /* TODO, we may want object mode blending */
 -                              if(em)  dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +                              if(em)  dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
                                else    dvert= dvert_array+i2;
  
                                dw= defvert_find_index(dvert, def_nr);
                }
  
                i= 0;
 -              for(eve= em->verts.first; eve; eve= eve->next) {
 -                      if(eve->f & SELECT && vg_users[i] > 0) {
 +              BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                      if(BM_TestHFlag(eve, BM_SELECT) && vg_users[i] > 0) {
                                /* TODO, we may want object mode blending */
 -                              if(em)  dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +                              if(em)  dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
                                else    dvert= dvert_array+i;
  
                                dw= defvert_verify_index(dvert, def_nr);
@@@ -1512,7 -1511,7 +1514,7 @@@ void ED_vgroup_mirror(Object *ob, cons
                          all_vgroups, def_nr                                   \
                          )
  
 -      EditVert *eve, *eve_mirr;
 +      BMVert *eve, *eve_mirr;
        MDeformVert *dvert, *dvert_mirr;
        short sel, sel_mirr;
        int     *flip_map, flip_map_len;
        /* only the active group */
        if(ob->type == OB_MESH) {
                Mesh *me= ob->data;
 -              EditMesh *em = BKE_mesh_get_editmesh(me);
 +              BMEditMesh *em = me->edit_btmesh;
  
                if (em) {
 -                      if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) {
 +                      BMIter iter;
 +
 +                      if(!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
                                goto cleanup;
                        }
  
 -                      EM_cache_x_mirror_vert(ob, em);
 +                      EDBM_CacheMirrorVerts(em, FALSE);
  
                        /* Go through the list of editverts and assign them */
 -                      for(eve=em->verts.first; eve; eve=eve->next){
 -                              if((eve_mirr=eve->tmp.v)) {
 -                                      sel= eve->f & SELECT;
 -                                      sel_mirr= eve_mirr->f & SELECT;
 +                      BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                              if((eve_mirr= EDBM_GetMirrorVert(em, eve))) {
 +                                      sel= BM_TestHFlag(eve, BM_SELECT);
 +                                      sel_mirr= BM_TestHFlag(eve_mirr, BM_SELECT);
  
                                        if((sel || sel_mirr) && (eve != eve_mirr)) {
 -                                              dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 -                                              dvert_mirr= CustomData_em_get(&em->vdata, eve_mirr->data, CD_MDEFORMVERT);
 +                                              dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
 +                                              dvert_mirr= CustomData_bmesh_get(&em->bm->vdata, eve_mirr->head.data, CD_MDEFORMVERT);
                                                if(dvert && dvert_mirr) {
                                                        VGROUP_MIRR_OP;
                                                }
                                        }
  
 -                                      eve->tmp.v= eve_mirr->tmp.v= NULL;
 +                                      /* don't use these again */
 +                                      EDBM_ClearMirrorVert(em, eve);
 +                                      EDBM_ClearMirrorVert(em, eve_mirr);
                                }
                        }
 -                      BKE_mesh_end_editmesh(me, em);
 +                      EDBM_EndMirrorCache(em);
                }
                else {
                        /* object mode / weight paint */
@@@ -1776,19 -1771,19 +1778,19 @@@ static void vgroup_active_remove_verts(
        if(ob->type == OB_MESH) {
                Mesh *me= ob->data;
  
 -              if (me->edit_mesh) {
 -                      EditVert *eve;
 -                      EditMesh *em = BKE_mesh_get_editmesh(me);
 +              if (me->edit_btmesh) {
 +                      BMEditMesh *em = me->edit_btmesh;
 +                      BMVert *eve;
 +                      BMIter iter;
  
 -                      for (eve=em->verts.first; eve; eve=eve->next) {
 -                              dv= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +                      BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                              dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
  
 -                              if (dv && dv->dw && (allverts || (eve->f & SELECT))) {
 +                              if(dv && dv->dw && (allverts || BM_TestHFlag(eve, BM_SELECT))) {
                                        MDeformWeight *dw = defvert_find_index(dv, def_nr);
                                        defvert_remove_group(dv, dw); /* dw can be NULL */
                                }
                        }
 -                      BKE_mesh_end_editmesh(me, em);
                }
                else {
                        MVert *mv;
@@@ -1846,19 -1841,19 +1848,19 @@@ static void vgroup_delete_edit_mode(Obj
        /* Make sure that any verts with higher indices are adjusted accordingly */
        if(ob->type==OB_MESH) {
                Mesh *me= ob->data;
 -              EditMesh *em = BKE_mesh_get_editmesh(me);
 -              EditVert *eve;
 +              BMEditMesh *em = me->edit_btmesh;
 +              BMIter iter;
 +              BMVert *eve;
                MDeformVert *dvert;
                
 -              for(eve=em->verts.first; eve; eve=eve->next){
 -                      dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +              BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                      dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
  
                        if(dvert)
                                for(i=0; i<dvert->totweight; i++)
                                        if(dvert->dw[i].def_nr > dg_index)
                                                dvert->dw[i].def_nr--;
                }
 -              BKE_mesh_end_editmesh(me, em);
        }
        else if(ob->type==OB_LATTICE) {
                Lattice *lt= vgroup_edit_lattice(ob);
                else if(ob->type==OB_LATTICE) {
                        Lattice *lt= vgroup_edit_lattice(ob);
                        if(lt->dvert) {
 -                              MEM_freeN(lt->dvert);
 +                              BLI_cellalloc_free(lt->dvert);
                                lt->dvert= NULL;
                        }
                }
  static int vgroup_object_in_edit_mode(Object *ob)
  {
        if(ob->type == OB_MESH)
 -              return (((Mesh*)ob->data)->edit_mesh != NULL);
 +              return (((Mesh*)ob->data)->edit_btmesh != NULL);
        else if(ob->type == OB_LATTICE)
                return (((Lattice*)ob->data)->editlatt != NULL);
        
@@@ -1920,7 -1915,7 +1922,7 @@@ static int vgroup_object_in_wpaint_vert
        if (ob->type == OB_MESH) {
                Mesh *me = ob->data;
                return ( (ob->mode & OB_MODE_WEIGHT_PAINT) &&
 -                       (me->edit_mesh == NULL) &&
 +                       (me->edit_btmesh == NULL) &&
                         (ME_EDIT_PAINT_SEL_MODE(me) == SCE_SELECT_VERTEX) );
        }
  
@@@ -1950,7 -1945,7 +1952,7 @@@ static void vgroup_delete_all(Object *o
        else if(ob->type==OB_LATTICE) {
                Lattice *lt= vgroup_edit_lattice(ob);
                if(lt->dvert) {
 -                      MEM_freeN(lt->dvert);
 +                      BLI_cellalloc_free(lt->dvert);
                        lt->dvert= NULL;
                }
        }
@@@ -1973,26 -1968,25 +1975,26 @@@ static void vgroup_assign_verts(Object 
  
        if(ob->type == OB_MESH) {
                Mesh *me= ob->data;
 -              if (me->edit_mesh) {
 -                      EditMesh *em = BKE_mesh_get_editmesh(me);
 -                      EditVert *eve;
  
 -                      if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT))
 -                              EM_add_data_layer(em, &em->vdata, CD_MDEFORMVERT, NULL);
 +              if (me->edit_btmesh) {
 +                      BMEditMesh *em = me->edit_btmesh;
 +                      BMIter iter;
 +                      BMVert *eve;
 +
 +                      if(!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT))
 +                              BM_add_data_layer(em->bm, &em->bm->vdata, CD_MDEFORMVERT);
  
                        /* Go through the list of editverts and assign them */
 -                      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)) {
                                        MDeformWeight *dw;
 -                                      dv= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT); /* can be NULL */
 +                                      dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); /* can be NULL */
                                        dw= defvert_verify_index(dv, def_nr);
                                        if (dw) {
                                                dw->weight= weight;
                                        }
                                }
                        }
 -                      BKE_mesh_end_editmesh(me, em);
                }
                else {
                        MVert *mv;
@@@ -2801,12 -2795,11 +2803,12 @@@ static int vgroup_do_remap(Object *ob, 
  
        if(ob->mode == OB_MODE_EDIT) {
                if(ob->type==OB_MESH) {
 -                      EditMesh *em = BKE_mesh_get_editmesh(ob->data);
 -                      EditVert *eve;
 +                      BMEditMesh *em = ((Mesh*)ob->data)->edit_btmesh;
 +                      BMIter iter;
 +                      BMVert *eve;
  
 -                      for(eve=em->verts.first; eve; eve=eve->next){
 -                              dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
 +                      BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                              dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT);
                                if(dvert && dvert->totweight){
                                        defvert_remap(dvert, sort_map, defbase_tot);
                                }
index bfd96c5868fcbeb7b1c00eb96d123bbd04cbce02,03fcee399bd9a68c362d5b0aee0444eb5db7bb1b..4ab3874d6fec43337bf44df6a2edcec6b924974f
@@@ -5,7 -5,7 +5,7 @@@ sources = env.Glob('intern/*.c'
  
  incs = '. ./intern'
  incs += ' #/intern/guardedalloc #/intern/decimation/extern #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include'
 -incs += ' ../render/extern/include ../blenloader'
 +incs += ' ../render/extern/include ../blenloader ../bmesh'
  incs += ' ../include ../blenlib ../makesdna ../makesrna ../blenkernel ../blenkernel/intern'
  incs += ' ../gpu'
  
@@@ -14,10 -14,10 +14,10 @@@ incs += ' ' + env['BF_ZLIB_INC'
  defs = []
  
  if env ['WITH_BF_BOOLEAN']:
-     incs += ' #/intern/dualcon'
      defs.append('WITH_MOD_BOOLEAN')
  
  if env['WITH_BF_REMESH']:
+     incs += ' #/intern/dualcon'
      defs.append('WITH_MOD_REMESH')
  
  if env ['WITH_BF_DECIMATE']: