diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_convert.cc | 26 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_convert.h | 5 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_undo.c | 1 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_undo.c | 3 |
4 files changed, 26 insertions, 9 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index f581e2967c0..dcbb14e3578 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -677,8 +677,16 @@ static int bm_to_mesh_shape_layer_index_from_kb(BMesh *bm, KeyBlock *currkey) * \param bm: The source BMesh. * \param key: The destination key. * \param mvert: The destination vertex array (in some situations it's coordinates are updated). + * \param active_shapekey_to_mvert: When editing a non-basis shape key, the coordinates for the + * basis are typically copied into the `mvert` array since it makes sense for the meshes + * vertex coordinates to match the "Basis" key. + * When enabled, skip this step and copy #BMVert.co directly to #MVert.co, + * See #BMeshToMeshParams.active_shapekey_to_mvert doc-string. */ -static void bm_to_mesh_shape(BMesh *bm, Key *key, MVert *mvert) +static void bm_to_mesh_shape(BMesh *bm, + Key *key, + MVert *mvert, + const bool active_shapekey_to_mvert) { KeyBlock *actkey = static_cast<KeyBlock *>(BLI_findlink(&key->block, bm->shapenr - 1)); @@ -762,12 +770,14 @@ static void bm_to_mesh_shape(BMesh *bm, Key *key, MVert *mvert) * In this case it's important to overwrite these coordinates with the basis-keys coordinates. */ bool update_vertex_coords_from_refkey = false; int cd_shape_offset_refkey = -1; - if ((actkey != key->refkey) && (cd_shape_keyindex_offset != -1)) { - const int refkey_uuid = bm_to_mesh_shape_layer_index_from_kb(bm, key->refkey); - if (refkey_uuid != -1) { - cd_shape_offset_refkey = CustomData_get_n_offset(&bm->vdata, CD_SHAPEKEY, refkey_uuid); - if (cd_shape_offset_refkey != -1) { - update_vertex_coords_from_refkey = true; + if (active_shapekey_to_mvert == false) { + if ((actkey != key->refkey) && (cd_shape_keyindex_offset != -1)) { + const int refkey_uuid = bm_to_mesh_shape_layer_index_from_kb(bm, key->refkey); + if (refkey_uuid != -1) { + cd_shape_offset_refkey = CustomData_get_n_offset(&bm->vdata, CD_SHAPEKEY, refkey_uuid); + if (cd_shape_offset_refkey != -1) { + update_vertex_coords_from_refkey = true; + } } } } @@ -1137,7 +1147,7 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh } if (me->key) { - bm_to_mesh_shape(bm, me->key, me->mvert); + bm_to_mesh_shape(bm, me->key, me->mvert, params->active_shapekey_to_mvert); } /* Run this even when shape keys aren't used since it may be used for hooks or vertex parents. */ diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.h b/source/blender/bmesh/intern/bmesh_mesh_convert.h index 8e87fc86b6d..0bd70749cb1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.h +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.h @@ -53,6 +53,11 @@ struct BMeshToMeshParams { * that have become invalid from updating the shape-key, see T71865. */ uint update_shapekey_indices : 1; + /** + * Instead of copying the basis shape-key into the #MVert array, + * copy the #BMVert.co directly to #MVert.co (used for reading undo data). + */ + uint active_shapekey_to_mvert : 1; struct CustomData_MeshMasks cd_mask_extra; }; /** diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c index 97f67060c82..3bebcdc9bae 100644 --- a/source/blender/editors/mesh/editmesh_undo.c +++ b/source/blender/editors/mesh/editmesh_undo.c @@ -602,6 +602,7 @@ static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key, Undo .calc_object_remap = false, .update_shapekey_indices = false, .cd_mask_extra = {.vmask = CD_MASK_SHAPE_KEYINDEX}, + .active_shapekey_to_mvert = true, })); um->selectmode = em->selectmode; diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c index e9997fe8d42..c3a48abcae1 100644 --- a/source/blender/editors/space_image/image_undo.c +++ b/source/blender/editors/space_image/image_undo.c @@ -557,7 +557,8 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init) if (changed) { BKE_image_mark_dirty(image, ibuf); - BKE_image_free_gputextures(image); /* force OpenGL reload */ + /* TODO(jbakker): only mark areas that are actually updated to improve performance. */ + BKE_image_partial_update_mark_full_update(image); if (ibuf->rect_float) { ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ |