[Bf-blender-cvs] [11cfa6c718b] master: Fix T90332: Auto-smooth crashes in edit-mode

Campbell Barton noreply at git.blender.org
Mon Aug 2 16:01:59 CEST 2021


Commit: 11cfa6c718b7851a30f203c92e53c4dc6451ae1a
Author: Campbell Barton
Date:   Mon Aug 2 23:58:55 2021 +1000
Branches: master
https://developer.blender.org/rB11cfa6c718b7851a30f203c92e53c4dc6451ae1a

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.

===================================================================

M	source/blender/bmesh/intern/bmesh_mesh_normals.c

===================================================================

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) {



More information about the Bf-blender-cvs mailing list