From f958560a990a8974446c2c63def7ba387dcfb275 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 17 Mar 2020 17:34:04 +0100 Subject: Multires: Properly support virtual modifiers for Apply Base The initial code from earlier from today didn't really work reliable since it is not possible to apply virtual modifiers but not the real multires one (in a situation like mesh with shapekeys and multires). New code uses less memory and has better performance for the case when there are actual modifiers leading the multires. The case when there is only multires will not be as performant as possible at this moment. --- .../blenkernel/intern/multires_reshape_apply_base.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern/multires_reshape_apply_base.c') diff --git a/source/blender/blenkernel/intern/multires_reshape_apply_base.c b/source/blender/blenkernel/intern/multires_reshape_apply_base.c index 958fb60bbdc..62418150ff1 100644 --- a/source/blender/blenkernel/intern/multires_reshape_apply_base.c +++ b/source/blender/blenkernel/intern/multires_reshape_apply_base.c @@ -189,16 +189,11 @@ void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *resh BLI_assert(object != NULL); BLI_assert(mmd != NULL); - /* If there are no modifiers prior to the multires can use base mesh as it have all the updated - * vertices already. */ - if (mmd->modifier.prev == NULL) { - BKE_subdiv_eval_update_from_mesh(reshape_context->subdiv, reshape_context->base_mesh, NULL); - } - else { - /* TODO(sergey): Possible optimization is to only evaluate new verticies positions without - * construction of the entire mesh. */ - Mesh *deformed_base_mesh = BKE_multires_create_deformed_base_mesh(depsgraph, object, mmd); - BKE_subdiv_eval_update_from_mesh(reshape_context->subdiv, deformed_base_mesh, NULL); - BKE_id_free(NULL, deformed_base_mesh); - } + float(*deformed_verts)[3] = BKE_multires_create_deformed_base_mesh_vert_coords( + depsgraph, object, mmd, NULL); + + BKE_subdiv_eval_update_from_mesh( + reshape_context->subdiv, reshape_context->base_mesh, deformed_verts); + + MEM_freeN(deformed_verts); } -- cgit v1.2.3