Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-01 12:11:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-01 12:11:55 +0400
commit2ad80bf3bb807a5d433406794becb6aaafd415f9 (patch)
treeb4caca35f1cdf2e31b6f14f2a9f4f180d0c86e77 /source/blender/blenkernel/intern/deform.c
parentbcdcbb65c159cc16b222fc5381e806a6b4f03fb0 (diff)
vertex group mirror
- now works in vertex select + weight paint mode. - added option not to mirror all vertex groups.
Diffstat (limited to 'source/blender/blenkernel/intern/deform.c')
-rw-r--r--source/blender/blenkernel/intern/deform.c42
1 files changed, 39 insertions, 3 deletions
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);