diff options
Diffstat (limited to 'source/blender/blenkernel/intern/deform.c')
-rw-r--r-- | source/blender/blenkernel/intern/deform.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index e5f2d152edf..37c551a05b7 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -260,6 +260,29 @@ void defvert_flip(MDeformVert *dvert, const int *flip_map, const int flip_map_le } } +void defvert_flip_merged(MDeformVert *dvert, const int *flip_map, const int flip_map_len) +{ + MDeformWeight *dw, *copydw; + float weight; + int i, totweight = dvert->totweight; + + /* copy weights */ + for (dw= dvert->dw, i=0; i<totweight; dw++, i++) { + if (dw->def_nr < flip_map_len) { + if (flip_map[dw->def_nr] >= 0) { + copydw= defvert_verify_index(dvert, flip_map[dw->def_nr]); + dw= &dvert->dw[i]; /* in case array got realloced */ + + /* distribute weights: if only one of the vertex groups was + assigned this will halve the weights, otherwise it gets + evened out. this keeps it proportional to other groups */ + weight = 0.5f*(copydw->weight + dw->weight); + copydw->weight= weight; + dw->weight= weight; + } + } + } +} bDeformGroup *defgroup_find_name(Object *ob, const char *name) { |