svn merge ^/trunk/blender -r43278:43294
authorCampbell Barton <ideasman42@gmail.com>
Wed, 11 Jan 2012 15:04:54 +0000 (15:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 11 Jan 2012 15:04:54 +0000 (15:04 +0000)
49 files changed:
1  2 
CMakeLists.txt
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/meshlaplacian.c
source/blender/editors/armature/reeb.c
source/blender/editors/curve/editcurve.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_hook.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_ops.c
source/blender/editors/object/object_relations.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_orientations.c
source/blender/editors/util/ed_util.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/makesdna/DNA_customdata_types.h
source/blender/makesdna/DNA_defs.h
source/blender/makesdna/DNA_key_types.h
source/blender/makesdna/DNA_modifier_types.h
source/blender/makesrna/intern/rna_modifier.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c
source/blender/modifiers/intern/MOD_armature.c
source/blender/modifiers/intern/MOD_bevel.c
source/blender/modifiers/intern/MOD_cast.c
source/blender/modifiers/intern/MOD_curve.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/modifiers/intern/MOD_hook.c
source/blender/modifiers/intern/MOD_lattice.c
source/blender/modifiers/intern/MOD_smooth.c
source/blender/modifiers/intern/MOD_util.c
source/blender/modifiers/intern/MOD_uvproject.c
source/blender/modifiers/intern/MOD_wave.c
source/blenderplayer/bad_level_call_stubs/stubs.c

diff --cc CMakeLists.txt
Simple merge
@@@ -1321,9 -1321,9 +1321,9 @@@ void dynamicPaint_setInitialColor(Dynam
        else if (surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) {
                Tex *tex = surface->init_texture;
                MTFace *tface;
 -              MFace *mface = dm->getFaceArray(dm);
 -              int numOfFaces = dm->getNumFaces(dm);
 +              MFace *mface = dm->getTessFaceArray(dm);
 +              int numOfFaces = dm->getNumTessFaces(dm);
-               char uvname[40];
+               char uvname[MAX_CUSTOMDATA_LAYER_NAME];
  
                if (!tex) return;
  
@@@ -45,6 -44,8 +45,7 @@@
  #include "BLI_math.h"
  #include "BLI_edgehash.h"
  #include "BLI_memarena.h"
 -#include "BLI_utildefines.h"
+ #include "BLI_string.h"
  
  #include "BKE_DerivedMesh.h"
  #include "BKE_modifier.h"
@@@ -551,32 -533,21 +551,32 @@@ static int draw_tface_mapped__set_draw(
  static int draw_em_tf_mapped__set_draw(void *userData, int index)
  {
        drawEMTFMapped_userData *data = userData;
 -      EditMesh *em = data->em;
 -      EditFace *efa= EM_get_face_for_index(index);
 -      MTFace *tface;
 -      int matnr;
 +      BMEditMesh *em = data->em;
 +      BMFace *efa= EDBM_get_face_for_index(em, index);
  
 -      if (efa->h)
 +      if (efa==NULL || BM_TestHFlag(efa, BM_HIDDEN)) {
                return 0;
 +      }
 +      else {
 +              MTFace mtf= {{{0}}};
 +              int matnr = efa->mat_nr;
 +
 +              if (data->has_mtface) {
 +                      MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
 +                      mtf.flag = tpoly->flag;
 +                      mtf.tpage = tpoly->tpage;
 +                      mtf.transp = tpoly->transp;
 +                      mtf.mode = tpoly->mode;
 +                      mtf.tile = tpoly->tile;
 +                      mtf.unwrap = tpoly->unwrap;
  
 -      tface = data->has_mtface ? CustomData_em_get(&em->fdata, efa->data, CD_MTFACE) : NULL;
 -      matnr = efa->mat_nr;
 +              }
  
 -      return draw_tface__set_draw_legacy(tface, data->has_mcol, matnr);
 +              return draw_tface__set_draw_legacy(&mtf, data->has_mcol, matnr);
 +      }
  }
  
- static int wpaint__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r)
+ static int wpaint__setSolidDrawOptions_material(void *userData, int index, int *drawSmooth_r)
  {
        Mesh *me = (Mesh*)userData;
  
@@@ -729,9 -710,9 +739,9 @@@ void draw_mesh_textured_old(Scene *scen
        }
        else if(draw_flags & DRAW_FACE_SELECT) {
                if(ob->mode & OB_MODE_WEIGHT_PAINT)
-                       dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, GPU_enable_material, NULL, me, 1);
+                       dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions_facemask, GPU_enable_material, NULL, me, 1);
                else
 -                      dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, NULL, me);
 +                      dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, NULL, me);
        }
        else {
                if(GPU_buffer_legacy(dm)) {
@@@ -2715,11 -2656,14 +2715,11 @@@ static void draw_em_fancy_edges(BMEditM
        }
  }     
  
 -static void draw_em_measure_stats(View3D *v3d, Object *ob, EditMesh *em, UnitSettings *unit)
 +static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitSettings *unit)
  {
        Mesh *me= ob->data;
 -      EditEdge *eed;
 -      EditFace *efa;
 -      float v1[3], v2[3], v3[3], v4[3], vmid[3];
 -      float fvec[3];
 +      float v1[3], v2[3], v3[3], vmid[3], fvec[3];
-       char val[32]; /* Stores the measurement display text here */
+       char numstr[32]; /* Stores the measurement display text here */
        const char *conv_float; /* Use a float conversion matching the grid size */
        unsigned char col[4]= {0, 0, 0, 255}; /* color of the text to draw */
        float area; /* area of the face */
        }
  
        if(me->drawflag & ME_DRAWEXTRA_FACEAREA) {
 -// XXX                extern int faceselectedOR(EditFace *efa, int flag);             // editmesh.h shouldn't be in this file... ok for now?
 +              /* would be nice to use BM_Compute_Face_Area, but that is for 2d faces
 +              so instead add up tessalation triangle areas */
 +              BMFace *f;
 +              int n;
 +
- #define DRAW_EM_MEASURE_STATS_FACEAREA()\
-               if (BM_TestHFlag(f, BM_SELECT)) {\
-                       mul_v3_fl(vmid, 1.0/n);\
-                       if(unit->system)\
-                               bUnit_AsString(val, sizeof(val), area*unit->scale_length,\
-                                       3, unit->system, B_UNIT_LENGTH, do_split, FALSE);\
-                       else\
-                               sprintf(val, conv_float, area);\
-                       view3d_cached_text_draw_add(vmid, val, 0, V3D_CACHE_TEXT_ASCII, col);\
++#define DRAW_EM_MEASURE_STATS_FACEAREA()                                             \
++              if (BM_TestHFlag(f, BM_SELECT)) {                                            \
++                      mul_v3_fl(vmid, 1.0/n);                                                  \
++                      if(unit->system)                                                         \
++                              bUnit_AsString(numstr, sizeof(numstr), area*unit->scale_length,      \
++                                      3, unit->system, B_UNIT_LENGTH, do_split, FALSE);                \
++                      else                                                                     \
++                              BLI_snprintf(numstr, sizeof(numstr), conv_float, area);              \
++                      view3d_cached_text_draw_add(vmid, numstr, 0, V3D_CACHE_TEXT_ASCII, col); \
 +              }
 +
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
                
 -              for(efa= em->faces.first; efa; efa= efa->next) {
 -                      if((efa->f & SELECT)) { // XXX || (do_moving && faceselectedOR(efa, SELECT)) ) {
 -                              copy_v3_v3(v1, efa->v1->co);
 -                              copy_v3_v3(v2, efa->v2->co);
 -                              copy_v3_v3(v3, efa->v3->co);
 -                              if (efa->v4) {
 -                                      copy_v3_v3(v4, efa->v4->co);
 -                              }
 -                              if(do_global) {
 -                                      mul_mat3_m4_v3(ob->obmat, v1);
 -                                      mul_mat3_m4_v3(ob->obmat, v2);
 -                                      mul_mat3_m4_v3(ob->obmat, v3);
 -                                      if (efa->v4) mul_mat3_m4_v3(ob->obmat, v4);
 -                              }
 -                              
 -                              if (efa->v4)
 -                                      area=  area_quad_v3(v1, v2, v3, v4);
 -                              else
 -                                      area = area_tri_v3(v1, v2, v3);
 -
 -                              if(unit->system)
 -                                      bUnit_AsString(numstr, sizeof(numstr), area*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); // XXX should be B_UNIT_AREA
 -                              else
 -                                      sprintf(numstr, conv_float, area);
 -
 -                              view3d_cached_text_draw_add(efa->cent, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
 +              f = NULL;
 +              area = 0.0;
 +              zero_v3(vmid);
 +              n = 0;
 +              for(i = 0; i < em->tottri; i++) {
 +                      BMLoop **l = em->looptris[i];
 +                      if(f && l[0]->f != f) {
 +                              DRAW_EM_MEASURE_STATS_FACEAREA();
 +                              zero_v3(vmid);
 +                              area = 0.0;
 +                              n = 0;
 +                      }
 +
 +                      f = l[0]->f;
 +                      copy_v3_v3(v1, l[0]->v->co);
 +                      copy_v3_v3(v2, l[1]->v->co);
 +                      copy_v3_v3(v3, l[2]->v->co);
 +                      if(do_global) {
 +                              mul_mat3_m4_v3(ob->obmat, v1);
 +                              mul_mat3_m4_v3(ob->obmat, v2);
 +                              mul_mat3_m4_v3(ob->obmat, v3);
                        }
 +                      area += area_tri_v3(v1, v2, v3);
 +                      add_v3_v3(vmid, v1);
 +                      add_v3_v3(vmid, v2);
 +                      add_v3_v3(vmid, v3);
 +                      n += 3;
 +              }
 +
 +              if(f){
 +                      DRAW_EM_MEASURE_STATS_FACEAREA();
                }
 +#undef DRAW_EM_MEASURE_STATS_FACEAREA
        }
  
        if(me->drawflag & ME_DRAWEXTRA_FACEANG) {
 -              EditEdge *e1, *e2, *e3, *e4;
 +              BMFace *efa;
 +
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
 -              for(efa= em->faces.first; efa; efa= efa->next) {
 -                      copy_v3_v3(v1, efa->v1->co);
 -                      copy_v3_v3(v2, efa->v2->co);
 -                      copy_v3_v3(v3, efa->v3->co);
 -                      if(efa->v4) {
 -                              copy_v3_v3(v4, efa->v4->co); 
 -                      }
 -                      else {
 -                              copy_v3_v3(v4, v3);
 -                      }
 -                      if(do_global) {
 -                              mul_mat3_m4_v3(ob->obmat, v1);
 -                              mul_mat3_m4_v3(ob->obmat, v2);
 -                              mul_mat3_m4_v3(ob->obmat, v3);
 -                              mul_mat3_m4_v3(ob->obmat, v4); /* intentionally executed even for tri's */
 -                      }
 -                      
 -                      e1= efa->e1;
 -                      e2= efa->e2;
 -                      e3= efa->e3;
 -                      if(efa->e4) e4= efa->e4; else e4= e3;
 -                      
 -                      /* Calculate the angles */
 -                              
 -                      if( (e4->f & e1->f & SELECT) || (do_moving && (efa->v1->f & SELECT)) ) {
 -                              /* Vec 1 */
 -                              sprintf(numstr,"%.3g", RAD2DEGF(angle_v3v3v3(v4, v1, v2)));
 -                              interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f);
 -                              view3d_cached_text_draw_add(fvec, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
 -                      }
 -                      if( (e1->f & e2->f & SELECT) || (do_moving && (efa->v2->f & SELECT)) ) {
 -                              /* Vec 2 */
 -                              sprintf(numstr,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3)));
 -                              interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f);
 -                              view3d_cached_text_draw_add(fvec, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
 -                      }
 -                      if( (e2->f & e3->f & SELECT) || (do_moving && (efa->v3->f & SELECT)) ) {
 -                              /* Vec 3 */
 -                              if(efa->v4) 
 -                                      sprintf(numstr,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v4)));
 -                              else
 -                                      sprintf(numstr,"%.3g", RAD2DEGF(angle_v3v3v3(v2, v3, v1)));
 -                              interp_v3_v3v3(fvec, efa->cent, efa->v3->co, 0.8f);
 -                              view3d_cached_text_draw_add(fvec, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
 -                      }
 -                              /* Vec 4 */
 -                      if(efa->v4) {
 -                              if( (e3->f & e4->f & SELECT) || (do_moving && (efa->v4->f & SELECT)) ) {
 -                                      sprintf(numstr,"%.3g", RAD2DEGF(angle_v3v3v3(v3, v4, v1)));
 -                                      interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f);
 +
 +
 +              for(efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL);
 +                  efa; efa=BMIter_Step(&iter)) {
 +                      BMIter liter;
 +                      BMLoop *loop;
 +
 +                      BM_Compute_Face_CenterBounds(em->bm, efa, vmid);
 +
 +                      for(loop = BMIter_New(&liter, em->bm, BM_LOOPS_OF_FACE, efa);
 +                          loop; loop = BMIter_Step(&liter)) {
 +
 +                              float v1[3], v2[3], v3[3];
 +
 +                              copy_v3_v3(v1, loop->prev->v->co);
 +                              copy_v3_v3(v2, loop->v->co);
 +                              copy_v3_v3(v3, loop->next->v->co);
 +
 +                              if(do_global){
 +                                      mul_mat3_m4_v3(ob->obmat, v1);
 +                                      mul_mat3_m4_v3(ob->obmat, v2);
 +                                      mul_mat3_m4_v3(ob->obmat, v3);
 +                              }
 +
-                               if(BM_TestHFlag(efa, BM_SELECT) ||
-                                       (do_moving && BM_TestHFlag(loop->v, BM_SELECT))){
-                                       sprintf(val,"%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3)));
++                              if ( (BM_TestHFlag(efa, BM_SELECT)) ||
++                                   (do_moving && BM_TestHFlag(loop->v, BM_SELECT)))
++                              {
++                                      BLI_snprintf(numstr, sizeof(numstr), "%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3)));
 +                                      interp_v3_v3v3(fvec, vmid, v2, 0.8f);
-                                       view3d_cached_text_draw_add(fvec, val, 0, V3D_CACHE_TEXT_ASCII, col);
+                                       view3d_cached_text_draw_add(fvec, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
                                }
                        }
                }
        }
  }
  
 -static void draw_em_indices(EditMesh *em)
 +static void draw_em_indices(BMEditMesh *em)
  {
 -      EditEdge *e;
 -      EditFace *f;
 -      EditVert *v;
 +      BMEdge *e;
 +      BMFace *f;
 +      BMVert *v;
        int i;
-       char val[32];
+       char numstr[32];
        float pos[3];
        unsigned char col[4];
  
 -      /* For now, reuse appropriate theme colors from stats text colors */
 +      BMIter iter;
 +      BMesh *bm= em->bm;
  
 +      /* For now, reuse appropriate theme colors from stats text colors */
 +      i= 0;
        if (em->selectmode & SCE_SELECT_VERTEX) {
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
 -              for (v = em->verts.first, i = 0; v; v = v->next, i++) {
 -                      if (v->f & SELECT) {
 +              BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
 +                      if (BM_TestHFlag(v, BM_SELECT)) {
-                               sprintf(val, "%d", i);
-                               view3d_cached_text_draw_add(v->co, val, 0, V3D_CACHE_TEXT_ASCII, col);
+                               sprintf(numstr, "%d", i);
+                               view3d_cached_text_draw_add(v->co, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
                        }
 +                      i++;
                }
        }
  
        if (em->selectmode & SCE_SELECT_EDGE) {
 +              i= 0;
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
 -              for (e = em->edges.first, i = 0; e; e = e->next, i++) {
 -                      if (e->f & SELECT) {
 +              BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
 +                      if (BM_TestHFlag(e, BM_SELECT)) {
-                               sprintf(val, "%d", i);
+                               sprintf(numstr, "%d", i);
                                mid_v3_v3v3(pos, e->v1->co, e->v2->co);
-                               view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col);
+                               view3d_cached_text_draw_add(pos, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
                        }
 +                      i++;
                }
        }
  
        if (em->selectmode & SCE_SELECT_FACE) {
 +              i= 0;
                UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
 -              for (f = em->faces.first, i = 0; f; f = f->next, i++) {
 -                      if (f->f & SELECT) {
 +              BM_ITER(f, &iter, bm, BM_FACES_OF_MESH, NULL) {
 +                      if (BM_TestHFlag(f, BM_SELECT)) {
 +                              BM_Compute_Face_CenterMean(bm, f, pos);
-                               sprintf(val, "%d", i);
-                               view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col);
+                               sprintf(numstr, "%d", i);
 -                              view3d_cached_text_draw_add(f->cent, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
++                              view3d_cached_text_draw_add(pos, numstr, 0, V3D_CACHE_TEXT_ASCII, col);
                        }
 +                      i++;
                }
        }
  }
Simple merge
@@@ -47,7 -46,7 +47,8 @@@
  #include "BLI_editVert.h"
  #include "BLI_uvproject.h"
  #include "BLI_utildefines.h"
 +#include "BLI_rand.h"
+ #include "BLI_string.h"
  
  #include "BKE_context.h"
  #include "BKE_customdata.h"
@@@ -47,8 -47,8 +47,8 @@@ typedef struct CustomDataLayer 
        int active_rnd; /* number of the layer to render*/
        int active_clone; /* number of the layer to render*/
        int active_mask; /* number of the layer to render*/
 -      char pad[4];
 +      int uid;        /* shape keyblock unique id reference*/
-       char name[32];  /* layer name */
+       char name[64];  /* layer name, MAX_CUSTOMDATA_LAYER_AAME */
        void *data;     /* layer data */
  } CustomDataLayer;
  
  /* hrmf, we need a better include then this */
  #include "../blenloader/BLO_sys_types.h" /* needed for int64_t only! */
  
 -#define USE_BMESH_FORWARD_COMPAT
 +/* Must not be defined for BMesh, as this guards code for pre-BMesh code to load BMesh .blend files */
 +/* #define USE_BMESH_FORWARD_COMPAT */
  
+ /* non-id name variables should use this length */
+ #define MAX_NAME 64
  #endif /* DNA_DEFS_H */
@@@ -93,26 -93,24 +93,26 @@@ void get_texture_coords(MappingInfoModi
  
        /* UVs need special handling, since they come from faces */
        if(texmapping == MOD_DISP_MAP_UV) {
 -              if(CustomData_has_layer(&dm->faceData, CD_MTFACE)) {
 -                      MFace *mface = dm->getFaceArray(dm);
 -                      MFace *mf;
 +              if(CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) {
 +                      MPoly *mpoly = dm->getPolyArray(dm);
 +                      MPoly *mp;
 +                      MLoop *mloop = dm->getLoopArray(dm);
                        char *done = MEM_callocN(sizeof(*done) * numVerts,
                                                 "get_texture_coords done");
 -                      int numFaces = dm->getNumFaces(dm);
 +                      int numPolys = dm->getNumPolys(dm);
-                       char uvname[32];
+                       char uvname[MAX_CUSTOMDATA_LAYER_NAME];
 -                      MTFace *tf;
 +                      MLoopUV *mloop_uv;
  
 -                      CustomData_validate_layer_name(&dm->faceData, CD_MTFACE, dmd->uvlayer_name, uvname);
 -                      tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname);
 +                      CustomData_validate_layer_name(&dm->loopData, CD_MLOOPUV, dmd->uvlayer_name, uvname);
 +                      mloop_uv = CustomData_get_layer_named(&dm->loopData, CD_MLOOPUV, uvname);
  
                        /* verts are given the UV from the first face that uses them */
 -                      for(i = 0, mf = mface; i < numFaces; ++i, ++mf, ++tf) {
 -                              unsigned int fidx= mf->v4 ? 3:2;
 +                      for(i = 0, mp = mpoly; i < numPolys; ++i, ++mp) {
 +                              unsigned int fidx= mp->totloop - 1;
  
                                do {
 -                                      unsigned int vidx = *(&mf->v1 + fidx);
 +                                      unsigned int lidx= mp->loopstart + fidx;
 +                                      unsigned int vidx= mloop[lidx].v;
  
                                        if (done[vidx] == 0) {
                                                /* remap UVs from [0, 1] to [-1, 1] */