svn merge ^/trunk/blender -r42495:42516
authorCampbell Barton <ideasman42@gmail.com>
Thu, 8 Dec 2011 17:32:37 +0000 (17:32 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 8 Dec 2011 17:32:37 +0000 (17:32 +0000)
1  2 
source/blender/blenkernel/BKE_mesh.h
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/mesh_validate.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/modifiers/intern/MOD_hook.c
source/blender/modifiers/intern/MOD_weightvg_util.c

Simple merge
index 49ca4e139cc8770d14c8ad10aa34aef3d8170b00,8dfd7e25bfb56663ece7a93275ca56aef6543b0b..088241791a791b874ca13abeca358597f1e73f7f
@@@ -577,46 -574,61 +577,61 @@@ MDeformWeight *defvert_verify_index(MDe
        return dw_new;
  }
  
- /* Removes the given vertex from the vertex group, specified either by its defgrp_idx,
-  * or directly by its MDeformWeight pointer, if dw is not NULL.
-  * WARNING: This function frees the given MDeformWeight, do not use it afterward! */
- void defvert_remove_index(MDeformVert *dvert, int defgroup, MDeformWeight *dw)
+ /* TODO. merge with code above! */
+ /* Adds the given vertex to the specified vertex group, with given weight.
+  * warning, this does NOT check for existign, assume caller already knows its not there */
+ void defvert_add_index_notest(MDeformVert *dvert, int defgroup, const float weight)
  {
        MDeformWeight *dw_new;
-       int i;
  
-       /* Get index of removed MDeformWeight. */
-       if (dw == NULL) {
-               dw = dvert->dw;
-               for (i = dvert->totweight; i > 0; i--, dw++) {
-                       if (dw->def_nr == defgroup)
-                               break;
-               }
-               i--;
+       /* do this check always, this function is used to check for it */
+       if (!dvert || defgroup < 0)
+               return;
 -      dw_new = MEM_callocN(sizeof(MDeformWeight)*(dvert->totweight+1), "defvert_add_to group, new deformWeight");
++      dw_new = BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dvert->totweight+1), "defvert_add_to group, new deformWeight");
+       if(dvert->dw) {
+               memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*dvert->totweight);
 -              MEM_freeN(dvert->dw);
++              BLI_cellalloc_free(dvert->dw);
        }
-       else {
-               i = dw - dvert->dw;
+       dvert->dw = dw_new;
+       dw_new += dvert->totweight;
+       dw_new->weight = weight;
+       dw_new->def_nr = defgroup;
+       dvert->totweight++;
+ }
+ /* Removes the given vertex from the vertex group.
+  * WARNING: This function frees the given MDeformWeight, do not use it afterward! */
+ void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw)
+ {
+       if (dvert && dw) {
+               MDeformWeight *dw_new;
+               int i = dw - dvert->dw;
                /* Security check! */
-               if(i < 0 || i >= dvert->totweight)
+               if(i < 0 || i >= dvert->totweight) {
                        return;
-       }
+               }
  
-       dvert->totweight--;
-       /* If there are still other deform weights attached to this vert then remove
-        * this deform weight, and reshuffle the others.
-        */
-       if (dvert->totweight) {
-               dw_new = BLI_cellalloc_malloc(sizeof(MDeformWeight)*(dvert->totweight), __func__);
-               if (dvert->dw){
-                       memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i);
-                       memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i));
+               dvert->totweight--;
+               /* If there are still other deform weights attached to this vert then remove
+                * this deform weight, and reshuffle the others.
+                */
+               if (dvert->totweight) {
 -                      dw_new = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), __func__);
++                      dw_new = BLI_cellalloc_malloc(sizeof(MDeformWeight)*(dvert->totweight), __func__);
+                       if (dvert->dw){
+                               memcpy(dw_new, dvert->dw, sizeof(MDeformWeight)*i);
+                               memcpy(dw_new+i, dvert->dw+i+1, sizeof(MDeformWeight)*(dvert->totweight-i));
 -                              MEM_freeN(dvert->dw);
++                              BLI_cellalloc_free(dvert->dw);
+                       }
+                       dvert->dw = dw_new;
+               }
+               else {
+                       /* If there are no other deform weights left then just remove this one. */
 -                      MEM_freeN(dvert->dw);
 +                      BLI_cellalloc_free(dvert->dw);
+                       dvert->dw = NULL;
                }
-               dvert->dw = dw_new;
-       }
-       else {
-               /* If there are no other deform weights left then just remove this one. */
-               BLI_cellalloc_free(dvert->dw);
-               dvert->dw = NULL;
        }
  }
index 509cc821c656f150a884df303d8db6d6d91e51a0,c09e18e3ba0591857244630a2d2a6899f2e7a8db..fd19d8461d5eccfb72186ca7a6a22ea116573677
@@@ -384,7 -433,12 +433,12 @@@ int BKE_mesh_validate(Mesh *me, int do_
  
  int BKE_mesh_validate_dm(DerivedMesh *dm)
  {
-       return BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getTessFaceArray(dm), dm->getNumTessFaces(dm), TRUE, FALSE);
+       return BKE_mesh_validate_arrays(NULL,
 -                                      dm->getVertArray(dm), dm->getNumVerts(dm),
 -                                      dm->getEdgeArray(dm), dm->getNumEdges(dm),
 -                                      dm->getFaceArray(dm), dm->getNumFaces(dm),
 -                                      dm->getVertDataArray(dm, CD_MDEFORMVERT),
 -                                      TRUE, FALSE);
++                                    dm->getVertArray(dm), dm->getNumVerts(dm),
++                                    dm->getEdgeArray(dm), dm->getNumEdges(dm),
++                                    dm->getTessFaceArray(dm), dm->getNumTessFaces(dm),
++                                    dm->getVertDataArray(dm, CD_MDEFORMVERT),
++                                    TRUE, FALSE);
  }
  
  void BKE_mesh_calc_edges(Mesh *mesh, int update)
index f9c610a54b19afdae7d39e4dbfe3d33558ce03c9,f6f2c35163f760246249e2527af90cf9e48d050a..dd6e31ef8c4b4ede49a3b30734e7d48033b3a7d2
@@@ -3366,8 -3293,8 +3366,8 @@@ static int draw_mesh_object(Scene *scen
        Object *ob= base->object;
        Object *obedit= scene->obedit;
        Mesh *me= ob->data;
 -      EditMesh *em= me->edit_mesh;
 +      BMEditMesh *em= me->edit_btmesh;
-       int do_alpha_pass= 0, drawlinked= 0, retval= 0, glsl, check_alpha, i;
+       int do_alpha_after= 0, drawlinked= 0, retval= 0, glsl, check_alpha, i;
  
        /* If we are drawing shadows and any of the materials don't cast a shadow,
         * then don't draw the object */
index 3aaf0fbe6522ea1e9304c19aa65028e889502ba1,9e48c5d29e20b375aa0d9c059fafeca378fe8b82..e04d511336433e8a334ca6647554e83dc9c516ed
@@@ -251,17 -246,29 +246,29 @@@ static void deformVerts_do(HookModifier
        }
  }
  
- static void deformVertsEM(
-                                          ModifierData *md, Object *ob, struct BMEditMesh *editData,
-          DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
+ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData,
+                         float (*vertexCos)[3], int numVerts,
+                         int UNUSED(useRenderParams), int UNUSED(isFinalCalc))
  {
-       DerivedMesh *dm = derivedData;
+       HookModifierData *hmd = (HookModifierData*) md;
+       DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0);
  
-       if(!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, 0);
+       deformVerts_do(hmd, ob, dm, vertexCos, numVerts);
+       if(derivedData != dm)
+               dm->release(dm);
+ }
 -static void deformVertsEM(ModifierData *md, Object *ob, struct EditMesh *editData,
++static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData,
+                           DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
+ {
+       HookModifierData *hmd = (HookModifierData*) md;
+       DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0);
  
-       deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0);
+       deformVerts_do(hmd, ob, dm, vertexCos, numVerts);
  
-       if(!derivedData) dm->release(dm);
+       if(derivedData != dm)
+               dm->release(dm);
  }
  
  
index afaa29e91751705ef4bacb74a970833bb53a5578,5631b7e716ad3d0cf5c8f7b90c90bdaa888cda82..adfdaf073d69a13de350e539e43e5307cf1c298e
@@@ -223,25 -222,9 +223,6 @@@ void weightvg_do_mask(int num, const in
        }
  }
  
- /* Adds the given vertex to the specified vertex group, with given weight. */
- static void defvert_add_to_group(MDeformVert *dv, int defgrp_idx, const float weight)
- {
-       /* TODO, move into deform.c as a generic function. This assumes the vertex
-        * groups have already been checked, so this has to remain low level. */
-       MDeformWeight *newdw;
--
-       newdw = BLI_cellalloc_calloc(sizeof(MDeformWeight)*(dv->totweight+1), "defvert_add_to group, new deformWeight");
-       if(dv->dw) {
-               memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight);
-               BLI_cellalloc_free(dv->dw);
-       }
-       dv->dw = newdw;
-       dv->dw[dv->totweight].weight = weight;
-       dv->dw[dv->totweight].def_nr = defgrp_idx;
-       dv->totweight++;
- }
--
--
  /* Applies weights to given vgroup (defgroup), and optionnaly add/remove vertices from the group.
   * If dws is not NULL, it must be an array of MDeformWeight pointers of same length as weights (and
   * defgrp_idx can then have any value).