diff options
author | Campbell Barton <campbell@blender.org> | 2022-03-03 12:47:07 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-03-03 12:47:07 +0300 |
commit | ce0d4ea41c6ea8bba05b1dbf42eec2ac7438cb39 (patch) | |
tree | e48d6a043175c12835f8e7a28bbd5a550ded1cce /source | |
parent | d66b047ca39db33d91ae8a0435981d2a4b676d56 (diff) | |
parent | d961adb866cc2d7a95e4c6a7f06c49e346ec1abe (diff) |
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_convert.cc | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index ecdc86d31cf..f581e2967c0 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -753,6 +753,25 @@ static void bm_to_mesh_shape(BMesh *bm, Key *key, MVert *mvert) } } + /* Without this, the real mesh coordinates (uneditable) as soon as you create the Basis shape. + * while users might not notice since the shape-key is applied in the viewport, + * exporters for example may still use the underlying coordinates, see: T30771 & T96135. + * + * Needed when editing any shape that isn't the (`key->refkey`), the vertices in `me->mvert` + * currently have vertex coordinates set from the current-shape (initialized from #BMVert.co). + * 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; + } + } + } + LISTBASE_FOREACH (KeyBlock *, currkey, &key->block) { int keyi; float(*currkey_data)[3]; @@ -783,14 +802,12 @@ static void bm_to_mesh_shape(BMesh *bm, Key *key, MVert *mvert) if (currkey == actkey) { copy_v3_v3(currkey_data[i], eve->co); - if (actkey != key->refkey) { - /* Without this, the real mesh coordinates (uneditable) as soon as you create - * the Basis shape, see: T30771 for details. */ - if (cd_shape_keyindex_offset != -1) { - keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset); - if (keyi != ORIGINDEX_NONE) { - copy_v3_v3(mvert[i].co, co_orig); - } + if (update_vertex_coords_from_refkey) { + BLI_assert(actkey != key->refkey); + keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset); + if (keyi != ORIGINDEX_NONE) { + float *co_refkey = (float *)BM_ELEM_CD_GET_VOID_P(eve, cd_shape_offset_refkey); + copy_v3_v3(mvert[i].co, co_refkey); } } } |