diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-01-04 00:10:15 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-01-16 22:24:55 +0300 |
commit | b05bca23641fc8760b1c340928654f23ea04c6f2 (patch) | |
tree | bbba6e4328f18542a9a305f00f96010b58d816b7 /source/blender/modifiers/intern | |
parent | d72ffb5e9a40fc2a29e76c999915103e57bffd32 (diff) |
Fix (unreported) surface deform modifier not reporting its errors in the
UI
Seems like we need to set the error with the evaluated ModifierData.
Pass this to 'surfacedeformBind' and report with that.
Differential Revision: https://developer.blender.org/D6601
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index de32b90a5e3..6ec7d1069de 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -979,7 +979,8 @@ static void bindVert(void *__restrict userdata, freeBindData(bwdata); } -static bool surfacedeformBind(SurfaceDeformModifierData *smd, +static bool surfacedeformBind(SurfaceDeformModifierData *smd_orig, + SurfaceDeformModifierData *smd_eval, float (*vertexCos)[3], uint numverts, uint tnumpoly, @@ -999,38 +1000,38 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd, vert_edges = MEM_calloc_arrayN(tnumverts, sizeof(*vert_edges), "SDefVertEdgeMap"); if (vert_edges == NULL) { - modifier_setError((ModifierData *)smd, "Out of memory"); + modifier_setError((ModifierData *)smd_eval, "Out of memory"); return false; } adj_array = MEM_malloc_arrayN(tnumedges, 2 * sizeof(*adj_array), "SDefVertEdge"); if (adj_array == NULL) { - modifier_setError((ModifierData *)smd, "Out of memory"); + modifier_setError((ModifierData *)smd_eval, "Out of memory"); MEM_freeN(vert_edges); return false; } edge_polys = MEM_calloc_arrayN(tnumedges, sizeof(*edge_polys), "SDefEdgeFaceMap"); if (edge_polys == NULL) { - modifier_setError((ModifierData *)smd, "Out of memory"); + modifier_setError((ModifierData *)smd_eval, "Out of memory"); MEM_freeN(vert_edges); MEM_freeN(adj_array); return false; } - smd->verts = MEM_malloc_arrayN(numverts, sizeof(*smd->verts), "SDefBindVerts"); - if (smd->verts == NULL) { - modifier_setError((ModifierData *)smd, "Out of memory"); + smd_orig->verts = MEM_malloc_arrayN(numverts, sizeof(*smd_orig->verts), "SDefBindVerts"); + if (smd_orig->verts == NULL) { + modifier_setError((ModifierData *)smd_eval, "Out of memory"); freeAdjacencyMap(vert_edges, adj_array, edge_polys); return false; } BKE_bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 2); if (treeData.tree == NULL) { - modifier_setError((ModifierData *)smd, "Out of memory"); + modifier_setError((ModifierData *)smd_eval, "Out of memory"); freeAdjacencyMap(vert_edges, adj_array, edge_polys); - MEM_freeN(smd->verts); - smd->verts = NULL; + MEM_freeN(smd_orig->verts); + smd_orig->verts = NULL; return false; } @@ -1038,16 +1039,16 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd, mpoly, medge, mloop, tnumpoly, tnumedges, vert_edges, adj_array, edge_polys); if (adj_result == MOD_SDEF_BIND_RESULT_NONMANY_ERR) { - modifier_setError((ModifierData *)smd, "Target has edges with more than two polygons"); + modifier_setError((ModifierData *)smd_eval, "Target has edges with more than two polygons"); freeAdjacencyMap(vert_edges, adj_array, edge_polys); free_bvhtree_from_mesh(&treeData); - MEM_freeN(smd->verts); - smd->verts = NULL; + MEM_freeN(smd_orig->verts); + smd_orig->verts = NULL; return false; } - smd->numverts = numverts; - smd->numpoly = tnumpoly; + smd_orig->numverts = numverts; + smd_orig->numpoly = tnumpoly; SDefBindCalcData data = { .treeData = &treeData, @@ -1058,22 +1059,22 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd, .mloop = mloop, .looptri = BKE_mesh_runtime_looptri_ensure(target), .targetCos = MEM_malloc_arrayN(tnumverts, sizeof(float[3]), "SDefTargetBindVertArray"), - .bind_verts = smd->verts, + .bind_verts = smd_orig->verts, .vertexCos = vertexCos, - .falloff = smd->falloff, + .falloff = smd_orig->falloff, .success = MOD_SDEF_BIND_RESULT_SUCCESS, }; if (data.targetCos == NULL) { - modifier_setError((ModifierData *)smd, "Out of memory"); - freeData((ModifierData *)smd); + modifier_setError((ModifierData *)smd_eval, "Out of memory"); + freeData((ModifierData *)smd_orig); return false; } - invert_m4_m4(data.imat, smd->mat); + invert_m4_m4(data.imat, smd_orig->mat); for (int i = 0; i < tnumverts; i++) { - mul_v3_m4v3(data.targetCos[i], smd->mat, mvert[i].co); + mul_v3_m4v3(data.targetCos[i], smd_orig->mat, mvert[i].co); } TaskParallelSettings settings; @@ -1084,28 +1085,28 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd, MEM_freeN(data.targetCos); if (data.success == MOD_SDEF_BIND_RESULT_MEM_ERR) { - modifier_setError((ModifierData *)smd, "Out of memory"); - freeData((ModifierData *)smd); + modifier_setError((ModifierData *)smd_eval, "Out of memory"); + freeData((ModifierData *)smd_orig); } else if (data.success == MOD_SDEF_BIND_RESULT_NONMANY_ERR) { - modifier_setError((ModifierData *)smd, "Target has edges with more than two polygons"); - freeData((ModifierData *)smd); + modifier_setError((ModifierData *)smd_eval, "Target has edges with more than two polygons"); + freeData((ModifierData *)smd_orig); } else if (data.success == MOD_SDEF_BIND_RESULT_CONCAVE_ERR) { - modifier_setError((ModifierData *)smd, "Target contains concave polygons"); - freeData((ModifierData *)smd); + modifier_setError((ModifierData *)smd_eval, "Target contains concave polygons"); + freeData((ModifierData *)smd_orig); } else if (data.success == MOD_SDEF_BIND_RESULT_OVERLAP_ERR) { - modifier_setError((ModifierData *)smd, "Target contains overlapping verts"); - freeData((ModifierData *)smd); + modifier_setError((ModifierData *)smd_eval, "Target contains overlapping verts"); + freeData((ModifierData *)smd_orig); } else if (data.success == MOD_SDEF_BIND_RESULT_GENERIC_ERR) { /* I know this message is vague, but I could not think of a way * to explain this with a reasonably sized message. * Though it shouldn't really matter all that much, * because this is very unlikely to occur */ - modifier_setError((ModifierData *)smd, "Target contains invalid polygons"); - freeData((ModifierData *)smd); + modifier_setError((ModifierData *)smd_eval, "Target contains invalid polygons"); + freeData((ModifierData *)smd_orig); } freeAdjacencyMap(vert_edges, adj_array, edge_polys); @@ -1216,7 +1217,7 @@ static void surfacedeformModifier_do(ModifierData *md, invert_m4_m4(tmp_mat, ob->obmat); mul_m4_m4m4(smd_orig->mat, tmp_mat, ob_target->obmat); - if (!surfacedeformBind(smd_orig, vertexCos, numverts, tnumpoly, tnumverts, target)) { + if (!surfacedeformBind(smd_orig, smd, vertexCos, numverts, tnumpoly, tnumverts, target)) { smd->flags &= ~MOD_SDEF_BIND; } /* Early abort, this is binding 'call', no need to perform whole evaluation. */ |