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.
This commit is contained in:
Campbell Barton 2021-08-09 18:32:53 +10:00
parent 52c349cfcd
commit 909e0819ae
Notes: blender-bot 2023-02-14 06:00:46 +01:00
Referenced by issue #90571, Mesh > Cleanup > Merge by distance...crash!
Referenced by issue #90557, Blender 3.0 crashes when performing Mesh -> Clean Up -> Merge By Distance in Edit Mode
Referenced by issue #90538, Deleting components in Edit mode leads to Blender crashes
Referenced by issue #90532, Seg fault crash with various edit functions
1 changed files with 3 additions and 8 deletions

View File

@ -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).