Fix T98056: Screw modifier crash with normal calculation and merging

If merging is enabled, the mesh might be recreated before
the dirty flag can be cleared, which means the normals aren't
valid anymore. To fix this, clearing the dirty flag should happen
before the merging. This is an existing bug, just exposed by
more recent explicit dirty normal tagging.
This commit is contained in:
Hans Goudey 2022-05-12 11:07:50 +02:00
parent 0eb2244f0a
commit cb5b33a627
Notes: blender-bot 2023-02-14 03:29:37 +01:00
Referenced by issue #98056, Crash opening a certain file with "Autosmooth" set
1 changed files with 4 additions and 4 deletions

View File

@ -1118,6 +1118,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
MEM_freeN(vert_loop_map);
}
if ((ltmd->flag & MOD_SCREW_NORMAL_CALC)) {
BKE_mesh_vertex_normals_clear_dirty(result);
}
if ((ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f)) {
result = mesh_remove_doubles_on_axis(result,
mvert_new,
@ -1128,10 +1132,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
ltmd->merge_dist);
}
if ((ltmd->flag & MOD_SCREW_NORMAL_CALC)) {
BKE_mesh_vertex_normals_clear_dirty(result);
}
return result;
}