[Bf-blender-cvs] [be32882e1c4] master: Fix T101883: Issue applying modifier to mesh with shape keys

Hans Goudey noreply at git.blender.org
Tue Oct 18 23:03:34 CEST 2022


Commit: be32882e1c40eb1cb72deab0bb6ee54fff917ca2
Author: Hans Goudey
Date:   Tue Oct 18 15:57:47 2022 -0500
Branches: master
https://developer.blender.org/rBbe32882e1c40eb1cb72deab0bb6ee54fff917ca2

Fix T101883: Issue applying modifier to mesh with shape keys

Caused by 21f2bacad977d3fd83d which misunderstood the logic handling
shape keys in this function. The shape key on the original mesh in the
main data-base should be cleared if the "no-main" mesh doesn't have any
shape key layers and the vertex count has changed. The complexity is
necessary because shape keys are stored differently on original and
evaluated meshes.

Also change to "Warn" because this is expected behavior in some cases,
like when applying a geometry nodes modifier that creates a new mesh
from scratch.

===================================================================

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 027423f5774..784d35a8d65 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -1313,6 +1313,7 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
   CustomData_duplicate_referenced_layers(&mesh_src->pdata, mesh_src->totpoly);
   CustomData_duplicate_referenced_layers(&mesh_src->ldata, mesh_src->totloop);
 
+  const bool verts_num_changed = mesh_dst->totvert != mesh_src->totvert;
   mesh_dst->totvert = mesh_src->totvert;
   mesh_dst->totedge = mesh_src->totedge;
   mesh_dst->totpoly = mesh_src->totpoly;
@@ -1339,11 +1340,10 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob)
       const int uid_active = ob ? find_object_active_key_uid(*key_dst, *ob) : -1;
       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);
-      if (mesh_src->key) {
-        id_us_min(&mesh_src->key->id);
-      }
+    else if (verts_num_changed) {
+      CLOG_WARN(&LOG, "Shape key data lost when replacing mesh '%s' in Main", mesh_src->id.name);
+      id_us_min(&mesh_dst->key->id);
+      mesh_dst->key = nullptr;
     }
   }



More information about the Bf-blender-cvs mailing list