[Bf-blender-cvs] [70f1711324e] master: Mesh: Remove unnecessary copy in modifier stack

Hans Goudey noreply at git.blender.org
Wed Aug 31 19:12:25 CEST 2022


Commit: 70f1711324e27e8189b401b40cc0f41564f15441
Author: Hans Goudey
Date:   Wed Aug 31 12:12:09 2022 -0500
Branches: master
https://developer.blender.org/rB70f1711324e27e8189b401b40cc0f41564f15441

Mesh: Remove unnecessary copy in modifier stack

These few lines making a copy of the final mesh were confusing.
The goal (I'm fairly certain) is to make sure the cage mesh and final
mesh aren't shared when applying the vertex coordinates to the final
mesh. This can be done more simply though, in a way that avoids
duplicating the final mesh if it already isn't shared.

This works well in some basic tests with different modifiers. Though
I doubt it was really a bottleneck anywhere, simplifying the modifier
stack internals is always nice.

Differential Revision: https://developer.blender.org/D15814

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

M	source/blender/blenkernel/intern/DerivedMesh.cc

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

diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index e83720e99f1..7ef6eaa64cd 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -1572,11 +1572,9 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
    * then we need to build one. */
   if (mesh_final) {
     if (deformed_verts) {
-      Mesh *mesh_tmp = BKE_mesh_copy_for_eval(mesh_final, false);
-      if (mesh_final != mesh_cage) {
-        BKE_id_free(nullptr, mesh_final);
+      if (mesh_final == mesh_cage) {
+        mesh_final = BKE_mesh_copy_for_eval(mesh_final, false);
       }
-      mesh_final = mesh_tmp;
       BKE_mesh_vert_coords_apply(mesh_final, deformed_verts);
     }
   }



More information about the Bf-blender-cvs mailing list