diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-15 03:53:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-15 03:53:46 +0400 |
commit | 27a56719a81867942a344f53aacc3e6170f5ba54 (patch) | |
tree | 2ef23dc9ac34ccbf1f4d244191e721608b3f0f08 /source | |
parent | 40a2c1a2921b50edd8b798e79b6bd2a6d94d7bba (diff) |
minor vertex group edits
* when freeing a deform weight, use one less memcpy call.
* vgroup_delete_object_mode(), was looping on the deform verts twice when it didn't need to.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 13 |
2 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index e14fd6827af..f7f10276ee4 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -645,9 +645,16 @@ void defvert_remove_group(MDeformVert *dvert, MDeformWeight *dw) if (dvert->totweight) { dw_new = MEM_mallocN(sizeof(MDeformWeight)*(dvert->totweight), __func__); if (dvert->dw) { +#if 1 /* since we dont care about order, swap this with the last, save a memcpy */ + if (i != dvert->totweight) { + dvert->dw[i]= dvert->dw[dvert->totweight]; + } + memcpy(dw_new, dvert->dw, sizeof(MDeformWeight) * dvert->totweight); + MEM_freeN(dvert->dw); +#else 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); +#endif } dvert->dw = dw_new; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 7d63d7dc270..50fe9d26cf9 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1697,7 +1697,7 @@ static void vgroup_delete_update_users(Object *ob, int id) static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) { MDeformVert *dvert_array=NULL; - int i, e, dvert_tot=0; + int dvert_tot=0; const int def_nr= BLI_findindex(&ob->defbase, dg); assert(def_nr > -1); @@ -1705,20 +1705,21 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) ED_vgroup_give_array(ob->data, &dvert_array, &dvert_tot); if(dvert_array) { + int i, j; MDeformVert *dv; for(i= 0, dv= dvert_array; i < dvert_tot; i++, dv++) { MDeformWeight *dw; dw= defvert_find_index(dv, def_nr); defvert_remove_group(dv, dw); /* dw can be NULL */ - } - for(i= 0, dv= dvert_array; i < dvert_tot; i++, dv++) { - for(e = 0; e < dv->totweight; e++) { - if(dv->dw[e].def_nr > def_nr) { - dv->dw[e].def_nr--; + /* inline, make into a function if anything else needs to do this */ + for(j = 0; j < dv->totweight; j++) { + if(dv->dw[j].def_nr > def_nr) { + dv->dw[j].def_nr--; } } + /* done */ } } |