From 72309be398d01f0f8d5d99dd74d3c2b2b1e166c7 Mon Sep 17 00:00:00 2001 From: Chao Li Date: Thu, 25 May 2023 22:12:11 +0200 Subject: [PATCH] Mesh: Avoid position copying in corrective smooth modifier This is a place where copying mesh position is not needed. See #103789. Pull Request: https://projects.blender.org/blender/blender/pulls/108291 --- .../modifiers/intern/MOD_correctivesmooth.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.cc b/source/blender/modifiers/intern/MOD_correctivesmooth.cc index dfaf75521c6..71a0006fe87 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.cc +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.cc @@ -653,12 +653,17 @@ static void correctivesmooth_modifier_do(ModifierData *md, } else { int me_numVerts; - rest_coords = em ? BKE_editmesh_vert_coords_alloc_orco(em, &me_numVerts) : - BKE_mesh_vert_coords_alloc(static_cast(ob->data), - &me_numVerts); + if (em) { + rest_coords = BKE_editmesh_vert_coords_alloc_orco(em, &me_numVerts); + is_rest_coords_alloc = true; + } + else { + const Mesh *me = static_cast(ob->data); + rest_coords = BKE_mesh_vert_positions(me); + me_numVerts = me->totvert; + } BLI_assert((uint)me_numVerts == verts_num); - is_rest_coords_alloc = true; } #ifdef DEBUG_TIME