diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_meshdeform.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshdeform.c | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 48653856178..e9e8c974413 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -275,10 +275,12 @@ static void meshdeform_vert_task( } static void meshdeformModifier_do( - ModifierData *md, Depsgraph *depsgraph, Object *ob, Mesh *mesh, + ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, float (*vertexCos)[3], int numVerts) { MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; + Object *ob = ctx->object; + Mesh *cagemesh; MDeformVert *dvert = NULL; float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4]; @@ -301,29 +303,9 @@ static void meshdeformModifier_do( * * We'll support this case once granular dependency graph is landed. */ - if (mmd->object->mode & OB_MODE_EDIT) { - BMEditMesh *em = BKE_editmesh_from_object(mmd->object); - cagemesh = BKE_bmesh_to_mesh_nomain(em->bm, &(struct BMeshToMeshParams){0}); - free_cagemesh = true; - } - else { - ModifierEvalContext ctx = { - .depsgraph = depsgraph, - .flag = md->mode & eModifierMode_Render ? MOD_APPLY_RENDER : 0, - }; - cagemesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, ob); - } - - /* if we don't have one computed, use derivedmesh from data - * without any modifiers */ - if (!cagemesh) { - cagemesh = get_mesh(mmd->object, NULL, NULL, NULL, false, false); - if (cagemesh) { - free_cagemesh = true; - } - } + cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, &free_cagemesh); - if (!cagemesh) { + if (cagemesh == NULL) { modifier_setError(md, "Cannot get mesh from cage object"); return; } @@ -412,7 +394,9 @@ static void meshdeformModifier_do( /* release cage derivedmesh */ MEM_freeN(dco); MEM_freeN(cagecos); - if (free_cagemesh) BKE_id_free(NULL, cagemesh); + if (cagemesh != NULL && free_cagemesh) { + BKE_id_free(NULL, cagemesh); + } } static void deformVerts( @@ -425,7 +409,7 @@ static void deformVerts( modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ - meshdeformModifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts); + meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts); if (mesh_src && mesh_src != mesh) { BKE_id_free(NULL, mesh_src); @@ -441,7 +425,7 @@ static void deformVertsEM( { Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); - meshdeformModifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts); + meshdeformModifier_do(md, ctx, mesh_src, vertexCos, numVerts); if (mesh_src && mesh_src != mesh) { BKE_id_free(NULL, mesh_src); |