diff options
Diffstat (limited to 'source/blender/modifiers/intern/MOD_surfacedeform.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index 20cc9b2392f..d9c0e0cc502 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -192,9 +192,7 @@ static void initData(ModifierData *md) MEMCPY_STRUCT_AFTER(smd, DNA_struct_default_get(SurfaceDeformModifierData), modifier); } -static void requiredDataMask(Object *UNUSED(ob), - ModifierData *md, - CustomData_MeshMasks *r_cddata_masks) +static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; @@ -215,8 +213,7 @@ static void freeData(ModifierData *md) MEM_SAFE_FREE(smd->verts[i].binds[j].vert_inds); MEM_SAFE_FREE(smd->verts[i].binds[j].vert_weights); } - - MEM_SAFE_FREE(smd->verts[i].binds); + MEM_freeN(smd->verts[i].binds); } } @@ -1172,10 +1169,10 @@ static bool surfacedeformBind(Object *ob, Mesh *mesh) { BVHTreeFromMesh treeData = {NULL}; - const MVert *mvert = target->mvert; - const MPoly *mpoly = target->mpoly; - const MEdge *medge = target->medge; - const MLoop *mloop = target->mloop; + const MVert *mvert = BKE_mesh_verts(target); + const MPoly *mpoly = BKE_mesh_polys(target); + const MEdge *medge = BKE_mesh_edges(target); + const MLoop *mloop = BKE_mesh_loops(target); uint tedges_num = target->totedge; int adj_result; SDefAdjacencyArray *vert_edges; @@ -1237,7 +1234,7 @@ static bool surfacedeformBind(Object *ob, smd_orig->target_polys_num = target_polys_num; int defgrp_index; - MDeformVert *dvert; + const MDeformVert *dvert; MOD_get_vgroup(ob, mesh, smd_orig->defgrp_name, &dvert, &defgrp_index); const bool invert_vgroup = (smd_orig->flags & MOD_SDEF_INVERT_VGROUP) != 0; const bool sparse_bind = (smd_orig->flags & MOD_SDEF_SPARSE_BIND) != 0; @@ -1449,7 +1446,7 @@ static void surfacedeformModifier_do(ModifierData *md, } Object *ob_target = smd->target; - target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false); + target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target); if (!target) { BKE_modifier_set_error(ob, md, "No valid target mesh"); return; @@ -1521,11 +1518,11 @@ static void surfacedeformModifier_do(ModifierData *md, * added after the original ones. This covers typical case when target was at the subdivision * level 0 and then subdivision was increased (i.e. for the render purposes). */ - BKE_modifier_set_error(ob, - md, - "Target vertices changed from %u to %u, continuing anyway", - smd->target_verts_num, - target_verts_num); + BKE_modifier_set_warning(ob, + md, + "Target vertices changed from %u to %u, continuing anyway", + smd->target_verts_num, + target_verts_num); /* In theory we only need the `smd->verts_num` vertices in the `targetCos` for evaluation, but * it is not currently possible to request a subset of coordinates: the API expects that the @@ -1539,7 +1536,7 @@ static void surfacedeformModifier_do(ModifierData *md, } int defgrp_index; - MDeformVert *dvert; + const MDeformVert *dvert; MOD_get_vgroup(ob, mesh, smd->defgrp_name, &dvert, &defgrp_index); const bool invert_vgroup = (smd->flags & MOD_SDEF_INVERT_VGROUP) != 0; @@ -1578,7 +1575,7 @@ static void deformVerts(ModifierData *md, if (smd->defgrp_name[0] != '\0') { /* Only need to use mesh_src when a vgroup is used. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src); @@ -1600,7 +1597,12 @@ static void deformVertsEM(ModifierData *md, if (smd->defgrp_name[0] != '\0') { /* Only need to use mesh_src when a vgroup is used. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false); + } + + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ + if (mesh_src != NULL) { + BKE_mesh_wrapper_ensure_mdata(mesh_src); } surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src); @@ -1741,7 +1743,7 @@ static void blendRead(BlendDataReader *reader, ModifierData *md) } ModifierTypeInfo modifierType_SurfaceDeform = { - /* name */ "SurfaceDeform", + /* name */ N_("SurfaceDeform"), /* structName */ "SurfaceDeformModifierData", /* structSize */ sizeof(SurfaceDeformModifierData), /* srna */ &RNA_SurfaceDeformModifier, |