From cb5b33a627d922019ded5765032baf182cee54a2 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 12 May 2022 11:07:50 +0200 Subject: [PATCH] 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. --- source/blender/modifiers/intern/MOD_screw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 05072cf340c..2082d9f3bba 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -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; }