diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-02 16:58:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-02 16:58:55 +0300 |
commit | 11cfa6c718b7851a30f203c92e53c4dc6451ae1a (patch) | |
tree | 3403fe9c2a6f96fd8a96923ff46665ec8beb9270 /source | |
parent | d60a7a87445c140a42b6470ef2c54c411d8e4bf3 (diff) |
Fix T90332: Auto-smooth crashes in edit-mode
Regression in 39b2a7bb7e815e051348bf5c5ec777d091324164
that meant non-manifold edges were not being tagged
when they should have been.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_normals.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_normals.c b/source/blender/bmesh/intern/bmesh_mesh_normals.c index 6dfaa0ca688..e62deb2dde5 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_normals.c +++ b/source/blender/bmesh/intern/bmesh_mesh_normals.c @@ -50,6 +50,8 @@ static void bm_edge_tag_from_smooth(const float (*fnos)[3], BMEdge *e, const float split_angle_cos); +static void bm_edge_tag_clear(BMEdge *e); + /* -------------------------------------------------------------------- */ /** \name Update Vertex & Face Normals * \{ */ @@ -820,9 +822,10 @@ BLI_INLINE bool bm_edge_is_smooth_no_angle_test(const BMEdge *e, const BMLoop *l_a, const BMLoop *l_b) { + BLI_assert(l_a->radial_next == l_b); return ( /* The face is manifold. */ - (l_a->radial_next == l_b) && + (l_b->radial_next == l_a) && /* Faces have winding that faces the same way. */ (l_a->v != l_b->v) && /* The edge is smooth. */ @@ -863,6 +866,13 @@ static void bm_edge_tag_from_smooth(const float (*fnos)[3], BMEdge *e, const flo } } +static void bm_edge_tag_clear(BMEdge *e) +{ + /* No need for atomics here as this is a single byte. */ + char *hflag_p = &e->head.hflag; + *hflag_p = *hflag_p & ~BM_ELEM_TAG; +} + /** * A version of #bm_edge_tag_from_smooth that sets sharp edges * when they would be considered smooth but exceed the split angle . @@ -944,9 +954,13 @@ static void bm_mesh_loops_calc_normals_for_vert_with_clnors(BMesh *bm, continue; } + /* Always set as #bm_mesh_loops_calc_normals_for_loop checks the tag. */ if (do_edge_tag) { bm_edge_tag_from_smooth(fnos, e_curr_iter, split_angle_cos); } + else { + bm_edge_tag_clear(e_curr_iter); + } do { /* Radial loops. */ if (l_curr->v != v) { @@ -1052,9 +1066,13 @@ static void bm_mesh_loops_calc_normals_for_vert_without_clnors( continue; } + /* Always set as #bm_mesh_loops_calc_normals_for_loop checks the tag. */ if (do_edge_tag) { bm_edge_tag_from_smooth(fnos, e_curr_iter, split_angle_cos); } + else { + bm_edge_tag_clear(e_curr_iter); + } do { /* Radial loops. */ if (l_curr->v != v) { |