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
This commit is contained in:
Hans Goudey 2022-08-31 12:12:09 -05:00
parent 91d9f46aec
commit 70f1711324
1 changed files with 2 additions and 4 deletions

View File

@ -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);
}
}