[Bf-blender-cvs] [d961adb866c] blender-v3.1-release: Fix T96135: Mesh coordinates are set to the last edited shape-key
Campbell Barton
noreply at git.blender.org
Thu Mar 3 10:45:28 CET 2022
Commit: d961adb866cc2d7a95e4c6a7f06c49e346ec1abe
Author: Campbell Barton
Date: Thu Mar 3 20:41:32 2022 +1100
Branches: blender-v3.1-release
https://developer.blender.org/rBd961adb866cc2d7a95e4c6a7f06c49e346ec1abe
Fix T96135: Mesh coordinates are set to the last edited shape-key
When exiting edit-mode set the vertex coordinates to the basis-shape when editing non-basis keys.
Regression in bfdbc78466ac14d45f353db9aa39cb21bb962701.
Reviewed By: sergey
Ref D14234
===================================================================
M source/blender/bmesh/intern/bmesh_mesh_convert.cc
===================================================================
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
index c7b414d2c0c..917e5c788e5 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
@@ -767,6 +767,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];
@@ -797,14 +816,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);
}
}
}
More information about the Bf-blender-cvs
mailing list