[Bf-blender-cvs] [81025104823] master: Fix T101583: Issues applying modifier to mesh with shape keys
Hans Goudey
noreply at git.blender.org
Tue Oct 4 19:10:25 CEST 2022
Commit: 8102510482362e83f509d90b86d31a10168ad72c
Author: Hans Goudey
Date: Tue Oct 4 12:09:44 2022 -0500
Branches: master
https://developer.blender.org/rB8102510482362e83f509d90b86d31a10168ad72c
Fix T101583: Issues applying modifier to mesh with shape keys
The wrong mesh was used to read the position attribute. Also, there was
always a warning about missing shape keys when that wasn't the case.
===================================================================
M source/blender/blenkernel/intern/mesh_convert.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index 1fd4bbd2bff..b4f729ca507 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -1260,12 +1260,15 @@ static int find_object_active_key_uid(const Key &key, const Object &object)
return kb->uid;
}
-static void move_shapekey_layers_to_keyblocks(Mesh &mesh, Key &key_dst, const int actshape_uid)
+static void move_shapekey_layers_to_keyblocks(const Mesh &mesh,
+ CustomData &custom_data,
+ Key &key_dst,
+ const int actshape_uid)
{
using namespace blender::bke;
- for (const int i : IndexRange(CustomData_number_of_layers(&mesh.vdata, CD_SHAPEKEY))) {
- const int layer_index = CustomData_get_layer_index_n(&mesh.vdata, CD_SHAPEKEY, i);
- CustomDataLayer &layer = mesh.vdata.layers[layer_index];
+ for (const int i : IndexRange(CustomData_number_of_layers(&custom_data, CD_SHAPEKEY))) {
+ const int layer_index = CustomData_get_layer_index_n(&custom_data, CD_SHAPEKEY, i);
+ CustomDataLayer &layer = custom_data.layers[layer_index];
KeyBlock *kb = keyblock_ensure_from_uid(key_dst, layer.uid, layer.name);
MEM_SAFE_FREE(kb->data);
@@ -1286,10 +1289,10 @@ static void move_shapekey_layers_to_keyblocks(Mesh &mesh, Key &key_dst, const in
LISTBASE_FOREACH (KeyBlock *, kb, &key_dst.block) {
if (kb->totelem != mesh.totvert) {
MEM_SAFE_FREE(kb->data);
+ kb->totelem = mesh.totvert;
+ kb->data = MEM_cnew_array<float3>(kb->totelem, __func__);
+ CLOG_ERROR(&LOG, "Data for shape key '%s' on mesh missing from evaluated mesh ", kb->name);
}
- kb->totelem = mesh.totvert;
- kb->data = MEM_cnew_array<float3>(kb->totelem, __func__);
- CLOG_ERROR(&LOG, "Data for shape key '%s' on mesh missing from evaluated mesh ", kb->name);
}
}
@@ -1334,7 +1337,7 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
if (CustomData_has_layer(&mesh_src->vdata, CD_SHAPEKEY)) {
/* If no object, set to -1 so we don't mess up any shapekey layers. */
const int uid_active = ob ? find_object_active_key_uid(*key_dst, *ob) : -1;
- move_shapekey_layers_to_keyblocks(*mesh_src, *key_dst, uid_active);
+ move_shapekey_layers_to_keyblocks(*mesh_dst, mesh_src->vdata, *key_dst, uid_active);
}
else if (mesh_src->totvert != mesh_dst->totvert) {
CLOG_ERROR(&LOG, "Mesh in Main '%s' lost shape keys", mesh_src->id.name);
More information about the Bf-blender-cvs
mailing list