[Bf-blender-cvs] [17567c235ac] master: Cleanup: Remove mesh edge "tmp tag"

Hans Goudey noreply at git.blender.org
Sun Jul 31 18:57:10 CEST 2022


Commit: 17567c235ac62f6d0f7e3bf0cea50593633099da
Author: Hans Goudey
Date:   Sun Jul 31 11:51:38 2022 -0500
Branches: master
https://developer.blender.org/rB17567c235ac62f6d0f7e3bf0cea50593633099da

Cleanup: Remove mesh edge "tmp tag"

Ref T95966. Also fixes modification of input mesh,
which should be considered constant.

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

M	source/blender/makesdna/DNA_meshdata_types.h
M	source/blender/modifiers/intern/MOD_solidify_extrude.c

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

diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 2a4234bde6a..4090c45a753 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -55,7 +55,6 @@ enum {
   /*  ME_HIDE = (1 << 4), */
   ME_EDGERENDER = (1 << 5),
   ME_LOOSEEDGE = (1 << 7),
-  ME_EDGE_TMP_TAG = (1 << 8),
   ME_SHARP = (1 << 9), /* only reason this flag remains a 'short' */
 };
 
diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 80af23054e4..4b744cd8350 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -53,7 +53,13 @@ BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref)
  * \param poly_nors: Precalculated face normals.
  * \param r_vert_nors: Return vert normals.
  */
-static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float (*r_vert_nors)[3])
+static void mesh_calc_hq_normal(Mesh *mesh,
+                                const float (*poly_nors)[3],
+                                float (*r_vert_nors)[3],
+#ifdef USE_NONMANIFOLD_WORKAROUND
+                                BLI_bitmap *edge_tmp_tag
+#endif
+)
 {
   int i, verts_num, edges_num, polys_num;
   MPoly *mpoly, *mp;
@@ -103,7 +109,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float (
           /* 3+ faces using an edge, we can't handle this usefully */
           edge_ref->p1 = edge_ref->p2 = -1;
 #ifdef USE_NONMANIFOLD_WORKAROUND
-          medge[ml->e].flag |= ME_EDGE_TMP_TAG;
+          BLI_BITMAP_ENABLE(edge_tmp_tag, ml->e);
 #endif
         }
         /* --- done --- */
@@ -319,9 +325,20 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
     BLI_assert(newEdges == 0);
   }
 
+#ifdef USE_NONMANIFOLD_WORKAROUND
+  BLI_bitmap *edge_tmp_tag = BLI_BITMAP_NEW(mesh->totedge, __func__);
+#endif
+
   if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
     vert_nors = MEM_calloc_arrayN(verts_num, sizeof(float[3]), "mod_solid_vno_hq");
-    mesh_calc_hq_normal(mesh, poly_nors, vert_nors);
+    mesh_calc_hq_normal(mesh,
+                        poly_nors,
+                        vert_nors
+#ifdef USE_NONMANIFOLD_WORKAROUND
+                        ,
+                        edge_tmp_tag
+#endif
+    );
   }
 
   result = BKE_mesh_new_nomain_from_template(mesh,
@@ -740,8 +757,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
 #ifdef USE_NONMANIFOLD_WORKAROUND
         /* skip 3+ face user edges */
         if ((check_non_manifold == false) ||
-            LIKELY(((orig_medge[ml[i_curr].e].flag & ME_EDGE_TMP_TAG) == 0) &&
-                   ((orig_medge[ml[i_next].e].flag & ME_EDGE_TMP_TAG) == 0))) {
+            LIKELY(!BLI_BITMAP_TEST(edge_tmp_tag, ml[i_curr].e) &&
+                   !BLI_BITMAP_TEST(edge_tmp_tag, ml[i_next].e))) {
           vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], poly_nors[i]) *
                                angle;
         }
@@ -949,6 +966,10 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
     MEM_freeN(vert_angles);
   }
 
+#ifdef USE_NONMANIFOLD_WORKAROUND
+  MEM_SAFE_FREE(edge_tmp_tag);
+#endif
+
   if (vert_nors) {
     MEM_freeN(vert_nors);
   }



More information about the Bf-blender-cvs mailing list