From b68ba3dae84233083f685332fa1ee31b0e98c324 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 11 Oct 2024 16:43:34 +1100 Subject: [PATCH] Fix #128839: "Apply Visual Geometry to Mesh" doesn't apply shape-keys Technically a regression in [0] although it matches behavior prior to v3.3 going back to 2.7x. The fix for #101883 [1] added a check for the vertex number changing after the number was zeroed, causing the shape key to be cleared in most cases. While the handling of shape-keys in OBJECT_OT_convert wasn't well defined - clearing the shape-key means in the evaluated coordinates are always used so it is preferable. Now the operator ensures the old (un-evaluated) shape-key isn't used. [0]: 0791f53029033b6c2a12f71ed6e86df09ab836f4 [1]: be32882e1c40eb1cb72deab0bb6ee54fff917ca2 --- source/blender/editors/object/object_add.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 37999d1ad6c..5840dc93583 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -3279,6 +3279,22 @@ static int object_convert_exec(bContext *C, wmOperator *op) } Mesh *ob_data_mesh = (Mesh *)newob->data; + + if (ob_data_mesh->key) { + /* NOTE(@ideasman42): Clearing the shape-key is needed when the + * number of vertices remains unchanged. Otherwise using this operator + * to "Apply Visual Geometry" will evaluate using the existing shape-key + * which doesn't have the "evaluated" coordinates from `new_mesh`. + * See #128839 for details. + * + * While shape-keys could be supported, this is more of a feature to consider. + * As there are already a `MESH_OT_blend_from_shape` operator, + * it's not clear this is especially useful or needed. */ + if (!CustomData_has_layer(&new_mesh->vert_data, CD_SHAPEKEY)) { + id_us_min(&ob_data_mesh->key->id); + ob_data_mesh->key = nullptr; + } + } BKE_mesh_nomain_to_mesh(new_mesh, ob_data_mesh, newob); BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */