svn merge -r40140:r40148 https://svn.blender.org/svnroot/bf-blender/trunk/blender
authorCampbell Barton <ideasman42@gmail.com>
Mon, 12 Sep 2011 04:57:20 +0000 (04:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 12 Sep 2011 04:57:20 +0000 (04:57 +0000)
17 files changed:
1  2 
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/particle.c
source/blender/blenlib/BLI_math_vector.h
source/blender/blenlib/intern/math_vector_inline.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sculpt_paint/sculpt_undo.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_manipulator.c
source/blender/editors/transform/transform_orientations.c
source/blender/editors/transform/transform_snap.c
source/blender/modifiers/intern/MOD_weightvgproximity.c

index 221002dae4ef0b8388fe85516a82b5ba6fee9655,468f39bf731b214ec613ec089cb3e48a98c3e015..c4a984773809ccc622045f2927e52d727e6d81cc
@@@ -597,9 -597,9 +597,9 @@@ int closest_point_on_surface(SurfaceMod
                }
  
                if(surface_vel) {
 -                      MFace *mface = CDDM_get_face(surmd->dm, nearest.index);
 +                      MFace *mface = CDDM_get_tessface(surmd->dm, nearest.index);
                        
-                       VECCOPY(surface_vel, surmd->v[mface->v1].co);
+                       copy_v3_v3(surface_vel, surmd->v[mface->v1].co);
                        add_v3_v3(surface_vel, surmd->v[mface->v2].co);
                        add_v3_v3(surface_vel, surmd->v[mface->v3].co);
                        if(mface->v4)
index c4fb9c2f3d61e105a9e051829aafb4f7afc4981e,82598e0b5c63cfd434438ad26a8fc0e21471686a..88a44b6cd8a76d9c19b257eba9d06c0b8d24a6d5
@@@ -4254,75 -4249,6 +4254,75 @@@ int BoneEnvelope(TransInfo *t, const in
  }
  
  /* ********************  Edge Slide   *************** */
-                       VECCOPY(vec, a);
 +static BMEdge *get_other_edge(BMesh *bm, BMVert *v, BMEdge *e)
 +{
 +      BMIter iter;
 +      BMEdge *e2;
 +
 +      BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, v) {
 +              if (BM_TestHFlag(e2, BM_SELECT) && e2 != e)
 +                      return e2;
 +      }
 +
 +      return NULL;
 +}
 +
 +static BMLoop *get_next_loop(BMesh *UNUSED(bm), BMVert *v, BMLoop *l, 
 +                             BMEdge *olde, BMEdge *nexte, float vec[3])
 +{
 +      BMLoop *firstl;
 +      float a[3] = {0.0f, 0.0f, 0.0f}, n[3] = {0.0f, 0.0f, 0.0f};
 +      int i=0;
 +
 +      firstl = l;
 +      do {
 +              l = BM_OtherFaceLoop(l->e, l->f, v);
 +              if (l->radial_next == l)
 +                      return NULL;
 +              
 +              if (l->e == nexte) {
 +                      if (i) {
 +                              mul_v3_fl(a, 1.0f / (float)i);
 +                      } else {
 +                              float f1[3], f2[3], f3[3];
 +
 +                              sub_v3_v3v3(f1, BM_OtherEdgeVert(olde, v)->co, v->co);
 +                              sub_v3_v3v3(f2, BM_OtherEdgeVert(nexte, v)->co, v->co);
 +
 +                              cross_v3_v3v3(f3, f1, l->f->no);
 +                              cross_v3_v3v3(a, f2, l->f->no);
 +                              mul_v3_fl(a, -1.0f);
 +
 +                              add_v3_v3(a, f3);
 +                              mul_v3_fl(a, 0.5f);
 +                      }
 +                      
-                       VECCOPY(vec, a);
++                      copy_v3_v3(vec, a);
 +                      return l;
 +              } else {
 +                      sub_v3_v3v3(n, BM_OtherEdgeVert(l->e, v)->co, v->co);
 +                      add_v3_v3v3(a, a, n);
 +                      i += 1;
 +              }
 +
 +              if (BM_OtherFaceLoop(l->e, l->f, v)->e == nexte) {
 +                      if (i)
 +                              mul_v3_fl(a, 1.0f / (float)i);
 +                      
-       VECCOPY(vec, a);
++                      copy_v3_v3(vec, a);
 +                      return BM_OtherFaceLoop(l->e, l->f, v);
 +              }
 +              
 +              l = l->radial_next;
 +      } while (l != firstl); 
 +
 +      if (i)
 +              mul_v3_fl(a, 1.0f / (float)i);
 +      
++      copy_v3_v3(vec, a);
 +      
 +      return NULL;
 +}
  
  static int createSlideVerts(TransInfo *t)
  {
@@@ -4795,27 -4828,108 +4795,27 @@@ void initEdgeSlide(TransInfo *t
  int doEdgeSlide(TransInfo *t, float perc)
  {
        SlideData *sld = t->customData;
 -      EditVert *ev, *nearest = sld->nearest;
 -      EditVert *centerVert, *upVert, *downVert;
 -      LinkNode *vertlist=sld->vertlist, *look;
 -      GHash *vertgh = sld->vhash;
 -      TransDataSlideVert *tempsv;
 -      float len;
 -      int prop=1, flip=0;
 -      /* UV correction vars */
 -      GHash **uvarray= sld->uvhash;
 -      const int  uvlay_tot= sld->uvlay_tot;
 -      int uvlay_idx;
 -      TransDataSlideUv *suv;
 -      float uv_tmp[2];
 -      LinkNode *fuv_link;
 -
 -      tempsv = BLI_ghash_lookup(vertgh,nearest);
 -
 -      centerVert = editedge_getSharedVert(tempsv->up, tempsv->down);
 -      upVert = editedge_getOtherVert(tempsv->up, centerVert);
 -      downVert = editedge_getOtherVert(tempsv->down, centerVert);
 -
 -      len = MIN2(perc, len_v3v3(upVert->co,downVert->co));
 -      len = MAX2(len, 0);
 -
 -      //Adjust Edgeloop
 -      if(prop) {
 -              look = vertlist;
 -              while(look) {
 -                      EditVert *tempev;
 -                      ev = look->link;
 -                      tempsv = BLI_ghash_lookup(vertgh,ev);
 -
 -                      tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev);
 -                      interp_v3_v3v3(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
 -
 -                      if (uvlay_tot) {
 -                              for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
 -                                      suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
 -                                      if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
 -                                              interp_v2_v2v2(uv_tmp, suv->origuv,  (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc));
 -                                              fuv_link = suv->fuv_list;
 -                                              while (fuv_link) {
 -                                                      VECCOPY2D(((float *)fuv_link->link), uv_tmp);
 -                                                      fuv_link = fuv_link->next;
 -                                              }
 -                                      }
 -                              }
 -                      }
 +      TransDataSlideVert *svlist = sld->sv, *sv;
 +      float vec[3];
 +      int i;
  
 -                      look = look->next;
 -              }
 -      }
 -      else {
 -              //Non prop code
 -              look = vertlist;
 -              while(look) {
 -                      float newlen, edgelen;
 -                      ev = look->link;
 -                      tempsv = BLI_ghash_lookup(vertgh,ev);
 -                      edgelen = len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co);
 -                      newlen = (edgelen != 0.0f)? (len / edgelen): 0.0f;
 -                      if(newlen > 1.0f) {newlen = 1.0;}
 -                      if(newlen < 0.0f) {newlen = 0.0;}
 -                      if(flip == 0) {
 -                              interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
 -                              if (uvlay_tot) {
 -                                      /* dont do anything if no UVs */
 -                                      for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
 -                                              suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
 -                                              if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
 -                                                      interp_v2_v2v2(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen));
 -                                                      fuv_link = suv->fuv_list;
 -                                                      while (fuv_link) {
 -                                                              VECCOPY2D(((float *)fuv_link->link), uv_tmp);
 -                                                              fuv_link = fuv_link->next;
 -                                                      }
 -                                              }
 -                                      }
 -                              }
 -                      } else{
 -                              interp_v3_v3v3(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
 -
 -                              if (uvlay_tot) {
 -                                      /* dont do anything if no UVs */
 -                                      for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
 -                                              suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
 -                                              if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
 -                                                      interp_v2_v2v2(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen));
 -                                                      fuv_link = suv->fuv_list;
 -                                                      while (fuv_link) {
 -                                                              VECCOPY2D(((float *)fuv_link->link), uv_tmp);
 -                                                              fuv_link = fuv_link->next;
 -                                                      }
 -                                              }
 -                                      }
 -                              }
 -                      }
 -                      look = look->next;
 -              }
 +      sld->perc = perc;
  
-                       VECCOPY(vec, sv->upvec);
 +      sv = svlist;
 +      for (i=0; i<sld->totsv; i++, sv++) {
 +              if (perc > 0.0f) {
-                       VECCOPY(vec, sv->downvec);
++                      copy_v3_v3(vec, sv->upvec);
 +                      mul_v3_fl(vec, perc);
 +                      add_v3_v3v3(sv->v->co, sv->origvert.co, vec);
 +              } else {
++                      copy_v3_v3(vec, sv->downvec);
 +                      mul_v3_fl(vec, -perc);
 +                      add_v3_v3v3(sv->v->co, sv->origvert.co, vec);
 +              }
        }
 -
 +      
 +      projectSVData(t, 0);
 +      
        return 1;
  }
  
index dbe881a56dccada9663d8b9e91f098664b8af5ad,b98cd277f80a2900cf276b04f0c26aca00ba353c..282ccdf47bf7930a122314738a02c2ae95eb6582
@@@ -1909,54 -1901,22 +1909,54 @@@ static void editmesh_set_connectivity_d
  }
  
  /* loop-in-a-loop I know, but we need it! (ton) */
 -static void get_face_center(float *cent, EditMesh *em, EditVert *eve)
 + static void get_face_center(float *centout, BMesh *bm, BMVert *eve)
 +
  {
 -      EditFace *efa;
 +      BMFace *efa;
 +      BMLoop *l;
 +      BMIter iter;
 +      float cent[3] = {0.0, 0.0, 0.0};
  
 -      for(efa= em->faces.first; efa; efa= efa->next)
 -              if(efa->f & SELECT)
 -                      if(efa->v1==eve || efa->v2==eve || efa->v3==eve || efa->v4==eve)
 -                              break;
 -      if(efa) {
 -              copy_v3_v3(cent, efa->cent);
 +      efa = BMIter_New(&iter, bm, BM_FACES_OF_VERT, eve);
 +      if (efa) {
 +              l = BMIter_New(&iter, bm, BM_LOOPS_OF_FACE, efa);
 +              for ( ; l; l=BMIter_Step(&iter)) {
 +                      VECADD(cent, cent, l->v->co);
 +              }
 +
 +              mul_v3_fl(cent, 1.0f / (float)efa->len);
        }
 +
 +      if (cent[0] == 0.0f && cent[1] == 0.0f && cent[2] == 0.0f) cent[2] = 1.0f;
 +      copy_v3_v3(centout, cent);
  }
  
-       VECCOPY(td->center, td->loc);\
 +#define VertsToTransData(t, td, em, eve, bweight) \
 +      td->flag = 0;\
 +      td->loc = eve->co;\
-       VECCOPY(td->iloc, td->loc);\
-       VECCOPY(td->axismtx[2], eve->no);\
++      copy_v3_v3(td->center, td->loc);\
 +      if(t->around==V3D_LOCAL && (em->selectmode & SCE_SELECT_FACE))\
 +              get_face_center(td->center, em, eve);\
++      copy_v3_v3(td->iloc, td->loc);\
++      copy_v3_v3(td->axismtx[2], eve->no);\
 +      td->axismtx[0][0]               =\
 +              td->axismtx[0][1]       =\
 +              td->axismtx[0][2]       =\
 +              td->axismtx[1][0]       =\
 +              td->axismtx[1][1]       =\
 +              td->axismtx[1][2]       = 0.0f;\
 +      td->ext = NULL;\
 +      td->val = NULL;\
 +      td->extra = NULL;\
 +      if (t->mode == TFM_BWEIGHT) {\
 +              td->val = bweight;\
 +              td->ival = bweight ? *(bweight) : 1.0f;\
 +      }
 +
 +#if 0
  //way to overwrite what data is edited with transform
  //static void VertsToTransData(TransData *td, EditVert *eve, BakeKey *key)
 -static void VertsToTransData(TransInfo *t, TransData *td, EditMesh *em, EditVert *eve)
 +inline void VertsToTransData(TransInfo *t, TransData *td, BMesh *em, BMVert *eve)
  {
        td->flag = 0;
        //if(key)
index 495ce8663cb85c32783be175141fa0eca16aa257,847fd951bccced5a2b52a0b708b133f7d3b1141a..663e5bdc061015fde05e4db68b181f9efcb7d508
@@@ -654,15 -652,14 +654,15 @@@ int getTransformOrientation(const bCont
  
                                        result = ORIENTATION_FACE;
                                }
 -                              else if (em->totedgesel == 1)
 +                              else if (em->bm->totedgesel == 1)
                                {
 -                                      EditEdge *eed;
 -
 -                                      for(eed= em->edges.first; eed; eed= eed->next) {
 -                                              if(eed->f & SELECT) {
 +                                      BMEdge *eed = NULL;
 +                                      BMIter iter;
 +                                      
 +                                      BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
 +                                              if(BM_TestHFlag(eed, BM_SELECT)) {
                                                        /* use average vert normals as plane and edge vector as normal */
-                                                       VECCOPY(plane, eed->v1->no);
+                                                       copy_v3_v3(plane, eed->v1->no);
                                                        VECADD(plane, plane, eed->v2->no);
                                                        sub_v3_v3v3(normal, eed->v2->co, eed->v1->co);
                                                        break;
                                        }
                                        result = ORIENTATION_EDGE;
                                }
 -                              else if (em->totvertsel == 1)
 +                              else if (em->bm->totvertsel == 1)
                                {
 -                                      for (eve = em->verts.first; eve; eve = eve->next)
 -                                      {
 -                                              if ( eve->f & SELECT ) {
 +                                      BMIter iter;
 +
 +                                      BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
 +                                              if (BM_TestHFlag(eve, BM_SELECT)) {
-                                                       VECCOPY(normal, eve->no);
+                                                       copy_v3_v3(normal, eve->no);
                                                        break;
                                                }
                                        }
                }
                
                if (ob) {
-                       VECCOPY(normal, ob->obmat[2]);
-                       VECCOPY(plane, ob->obmat[1]);
+                       copy_v3_v3(normal, ob->obmat[2]);
+                       copy_v3_v3(plane, ob->obmat[1]);
                }
 +              else {
 +                      normal[0] = 0.0f;
 +                      normal[1] = 0.0f;
 +                      normal[2] = 1.0f;
 +                      plane[0] = 1.0f;
 +                      plane[1] = 0.0f;
 +                      plane[2] = 0.0f;
 +              }
                result = ORIENTATION_NORMAL;
        }