diff options
author | Hans Goudey <h.goudey@me.com> | 2022-08-31 20:12:09 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-08-31 20:12:09 +0300 |
commit | 70f1711324e27e8189b401b40cc0f41564f15441 (patch) | |
tree | 664bf816521d7bc58fa82e10c36fc612e2eb6fcd /source/blender/blenkernel | |
parent | 91d9f46aecacab60d747b757cf57ecdc1b18913a (diff) |
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
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.cc | 6 |
1 files changed, 2 insertions, 4 deletions
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); } } |