From 2ad80bf3bb807a5d433406794becb6aaafd415f9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Nov 2011 08:11:55 +0000 Subject: vertex group mirror - now works in vertex select + weight paint mode. - added option not to mirror all vertex groups. --- source/blender/blenkernel/intern/deform.c | 42 ++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/deform.c') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 83eda860510..0c3c78f6eef 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -257,17 +257,19 @@ int defgroup_find_index (Object *ob, bDeformGroup *dg) /* note, must be freed */ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) { - bDeformGroup *dg; int totdg= *flip_map_len= BLI_countlist(&ob->defbase); if(totdg==0) { return NULL; } else { + bDeformGroup *dg; char name[sizeof(dg->name)]; int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), __func__); - memset(map, -1, totdg * sizeof(int)); + for (i=0; i < totdg; i++) { + map[i]= -1; + } for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) { if(map[i] == -1) { /* may be calculated previously */ @@ -276,7 +278,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) if(use_default) map[i]= i; - flip_side_name(name, dg->name, 0); + flip_side_name(name, dg->name, FALSE); if(strcmp(name, dg->name)) { flip_num= defgroup_name_index(ob, name); if(flip_num >= 0) { @@ -290,6 +292,40 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) } } +/* note, must be freed */ +int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, int defgroup) +{ + int totdg= *flip_map_len= BLI_countlist(&ob->defbase); + + if(totdg==0) { + return NULL; + } + else { + bDeformGroup *dg; + char name[sizeof(dg->name)]; + int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), __func__); + + for (i=0; i < totdg; i++) { + if (use_default) map[i]= i; + else map[i]= -1; + } + + dg= BLI_findlink(&ob->defbase, defgroup); + + flip_side_name(name, dg->name, FALSE); + if(strcmp(name, dg->name)) { + flip_num= defgroup_name_index(ob, name); + + if(flip_num >= 0) { + map[defgroup]= flip_num; + map[flip_num]= defgroup; + } + } + + return map; + } +} + int defgroup_flip_index(Object *ob, int index, int use_default) { bDeformGroup *dg= BLI_findlink(&ob->defbase, index); -- cgit v1.2.3