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>2019-11-27 22:12:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-11-27 22:17:14 +0300
commit7711231838e726055c6690757f3799dff90bfd96 (patch)
tree4e41e96ddaeb612dc128bf160c4baa8fafb60ded /source/blender/bmesh/intern
parente7502ee0aa8e27247689ef8debccaaa3b8b056bf (diff)
Fix T71865: Separating mesh parts breaks shape keys
This was an old bug which could be caused by saving after separating. Changes from 79b703bb635e made this fail reliably. Update shape key indices when they may be used again later.
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c10
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.h10
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index 9bcc9b9e84b..4e65ac40dd4 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -972,6 +972,16 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
if (ofs) {
MEM_freeN(ofs);
}
+
+ if (params->update_shapekey_indices) {
+ /* We have written a new shape key, if this mesh is _not_ going to be freed,
+ * update the shape key indices to match the newly updated. */
+ if (cd_shape_keyindex_offset != -1) {
+ BM_ITER_MESH_INDEX (eve, &iter, bm, BM_VERTS_OF_MESH, i) {
+ BM_ELEM_CD_SET_INT(eve, cd_shape_keyindex_offset, i);
+ }
+ }
+ }
}
if (oldverts != NULL) {
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.h b/source/blender/bmesh/intern/bmesh_mesh_conv.h
index f0302764a5f..65d5c6d5494 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.h
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.h
@@ -48,6 +48,16 @@ void BM_mesh_bm_from_me(BMesh *bm, const struct Mesh *me, const struct BMeshFrom
struct BMeshToMeshParams {
/** Update object hook indices & vertex parents. */
uint calc_object_remap : 1;
+ /**
+ * This re-assigns shape-key indices. Only do if the BMesh will have continued use
+ * to update the mesh & shape key in the future.
+ * In the case the BMesh is freed immediately, this can be left false.
+ *
+ * This is needed when flushing changes from edit-mode into object mode,
+ * so a second flush or edit-mode exit doesn't run with indices
+ * that have become invalid from updating the shape-key, see T71865.
+ */
+ uint update_shapekey_indices : 1;
struct CustomData_MeshMasks cd_mask_extra;
};
void BM_mesh_bm_to_me(struct Main *bmain,