From 909e0819ae939a8054bea2c9dcf389232744f3ae Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Aug 2021 18:32:53 +1000 Subject: Fix T90532: Crash editing meshes with auto-smooth Caused by fix for T90256 and a misunderstanding in D11928. Don't skip tagging edges when the auto-smooth angle is 180 degrees since this skips topology checks which are needed for properly calculating edge loop normals. --- source/blender/bmesh/intern/bmesh_mesh_normals.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'source/blender/bmesh') diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.c b/source/blender/bmesh/intern/bmesh_mesh_normals.c index 8eda38046a1..a5e41b74ee1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.c +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.c @@ -1116,8 +1116,6 @@ static void bm_mesh_loops_calc_normals__single_threaded(BMesh *bm, BMIter fiter; BMFace *f_curr; const bool has_clnors = clnors_data || (cd_loop_clnors_offset != -1); - const bool check_angle = (split_angle < (float)M_PI); - const float split_angle_cos = check_angle ? cosf(split_angle) : -1.0f; MLoopNorSpaceArray _lnors_spacearr = {NULL}; @@ -1152,16 +1150,13 @@ static void bm_mesh_loops_calc_normals__single_threaded(BMesh *bm, do { BM_elem_index_set(l_curr, index_loop++); /* set_inline */ BM_elem_flag_disable(l_curr, BM_ELEM_TAG); - /* Needed for when #bm_mesh_edges_sharp_tag doesn't run. - * Mark smooth if there is no smoothing angle. */ - BM_elem_flag_enable(l_curr->e, BM_ELEM_TAG); } while ((l_curr = l_curr->next) != l_first); } bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP); - if (split_angle_cos != -1.0f) { - bm_mesh_edges_sharp_tag(bm, fnos, has_clnors ? (float)M_PI : split_angle, false); - } + /* Always tag edges based on winding & sharp edge flag + * (even when the auto-smooth angle doesn't need to be calculated). */ + bm_mesh_edges_sharp_tag(bm, fnos, has_clnors ? (float)M_PI : split_angle, false); /* We now know edges that can be smoothed (they are tagged), * and edges that will be hard (they aren't). -- cgit v1.2.3