Fix T100191: Crash with the wave modifier using normals in edit-mode

This commit is contained in:
Campbell Barton 2022-08-12 21:45:21 +10:00
parent 4d2e2a6691
commit 4dc9a8a21e
Notes: blender-bot 2023-02-14 06:00:47 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93
Referenced by issue #100191, Regression: Crash on toggling display mode of wave modifier in edit mode
1 changed files with 11 additions and 1 deletions

View File

@ -327,8 +327,12 @@ static void deformVertsEM(ModifierData *md,
Mesh *mesh_src = NULL;
if (wmd->flag & MOD_WAVE_NORM) {
/* NOTE(@campbellbarton): don't request normals here because `use_normals == false`
* because #BKE_mesh_wrapper_ensure_mdata has not run yet.
* While this could be supported the argument is documented to be removed,
* so pass false here and let the normals be created when requested. */
mesh_src = MOD_deform_mesh_eval_get(
ctx->object, editData, mesh, vertexCos, verts_num, true, false);
ctx->object, editData, mesh, vertexCos, verts_num, false, false);
}
else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') {
mesh_src = MOD_deform_mesh_eval_get(
@ -343,6 +347,12 @@ static void deformVertsEM(ModifierData *md,
waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num);
if (!ELEM(mesh_src, NULL, mesh)) {
/* Important not to free `vertexCos` owned by the caller. */
EditMeshData *edit_data = mesh_src->runtime.edit_data;
if (edit_data->vertexCos == vertexCos) {
edit_data->vertexCos = NULL;
}
BKE_id_free(NULL, mesh_src);
}
}