Fix #32387: some mesh modifications breaking other shape keys.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 23 Aug 2012 13:54:30 +0000 (13:54 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 23 Aug 2012 13:54:30 +0000 (13:54 +0000)
The vertex shapekey index is now no longer copied, and propagation of offsets
in the basis to other shapekeys is disabled if new vertices were added. The
reason being that the propagation will only be done for the old vertices leaving
the new ones behind, and so doing e.g. subdivide + translate on the basis would
create a mess on other shape keys.

source/blender/bmesh/intern/bmesh_core.c
source/blender/bmesh/intern/bmesh_mesh_conv.c

index 8c8cc216e96a4bbe7b2bd9377e8e48148944d128..94d94cbec3eef251e4c09cf397d30f174e984bc5 100644 (file)
@@ -80,7 +80,14 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example)
        CustomData_bmesh_set_default(&bm->vdata, &v->head.data);
        
        if (example) {
+               int *keyi;
+
                BM_elem_attrs_copy(bm, bm, example, v);
+
+               /* exception: don't copy the original shapekey index */
+               keyi = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_SHAPE_KEYINDEX);
+               if(keyi)
+                       *keyi = ORIGINDEX_NONE;
        }
 
        BM_CHECK_ELEMENT(v);
index 123eb6829a36232261c251fa9f5b69f6f8837411..51c8b5d3bd8598c9c0175b0a873d344b6697afdf 100644 (file)
@@ -793,6 +793,15 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, int dotess)
                                        if (keyi && *keyi != ORIGINDEX_NONE) {
                                                sub_v3_v3v3(ofs[i], mvert->co, fp[*keyi]);
                                        }
+                                       else {
+                                               /* if there are new vertices in the mesh, we can't propagate the offset
+                                                * because it will only work for the existing vertices and not the new
+                                                * ones, creating a mess when doing e.g. subdivide + translate */
+                                               MEM_freeN(ofs);
+                                               ofs = NULL;
+                                               break;
+                                       }
+
                                        mvert++;
                                }
                        }