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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-03-20 01:09:16 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-03-20 01:09:16 +0400
commitf18dab65ad4af5e96ac439b68a773ddbb9c0074c (patch)
tree3cf2b887fdfc3458a2ebc3b0b9448457bc9f0f16 /source/blender
parent82979d5ab57217502b34977b5e5e82895bd66dbb (diff)
Fix #30531: mirror modifier with vertex groups did not add both the left and
right groups to merged vertices, only one. This made the result asymmetric, now merged vertices will be part of both groups with half weight.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_deform.h1
-rw-r--r--source/blender/blenkernel/intern/deform.c23
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c8
3 files changed, 30 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index 2e9c94a3bb1..96bad493a3e 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -64,6 +64,7 @@ void defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert
const int *flip_map, const int flip_map_len, const int use_verify);
void defvert_remap (struct MDeformVert *dvert, int *map, const int map_len);
void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
+void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
void defvert_normalize(struct MDeformVert *dvert);
void defvert_normalize_lock(struct MDeformVert *dvert, const int def_nr_lock);
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)
{
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 29b37acaeaf..b4129483c8d 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -272,8 +272,12 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd,
flip_map= defgroup_flip_map(ob, &flip_map_len, FALSE);
if (flip_map) {
- for (i = maxVerts; i-- > 0; dvert++) {
- defvert_flip(dvert, flip_map, flip_map_len);
+ for (i = 0; i < maxVerts; dvert++, i++) {
+ /* merged vertices get both groups, others get flipped */
+ if(do_vtargetmap && (vtargetmap[i] != -1))
+ defvert_flip_merged(dvert, flip_map, flip_map_len);
+ else
+ defvert_flip(dvert, flip_map, flip_map_len);
}
MEM_freeN(flip_map);