[Bf-blender-cvs] [05cc4cd0047] bevelv2: Initialize slope in mesh inset tests.

Howard Trickey noreply at git.blender.org
Tue Sep 20 14:02:39 CEST 2022


Commit: 05cc4cd0047492edf62c21c030ab131958b98da7
Author: Howard Trickey
Date:   Tue Sep 20 08:01:19 2022 -0400
Branches: bevelv2
https://developer.blender.org/rB05cc4cd0047492edf62c21c030ab131958b98da7

Initialize slope in mesh inset tests.

Also some format fixes, removal of unused functions, and fix
of a potential infinite loop in vertex normal calculation.

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

M	source/blender/blenlib/intern/mesh_inset.cc
M	source/blender/blenlib/tests/BLI_mesh_inset_test.cc

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

diff --git a/source/blender/blenlib/intern/mesh_inset.cc b/source/blender/blenlib/intern/mesh_inset.cc
index 58513280a69..6690e28e738 100644
--- a/source/blender/blenlib/intern/mesh_inset.cc
+++ b/source/blender/blenlib/intern/mesh_inset.cc
@@ -294,7 +294,8 @@ class Triangle {
 
   /* Our algorithm cares about which edges are original edges
    * (i.e., not triangulation edges). */
-  void mark_orig(int pos) {
+  void mark_orig(int pos)
+  {
     flags_ |= (TORIG0 << pos);
     Edge en = neighbor_[pos];
     if (!en.is_null()) {
@@ -353,11 +354,6 @@ void set_mutual_neighbors(Triangle *t1, int pos1, Edge e2)
   t2->neighbor_[e2.tri_edge_index()] = Edge(t1, pos1);
 }
 
-static bool triangle_id_less(const Triangle *a, const Triangle *b)
-{
-  return a->id() < b->id();
-}
-
 /** Return the vertex at the source end of \a e. */
 static Vert *v_src(Edge e)
 {
@@ -448,14 +444,13 @@ static float3 vertex_normal(const Vert *vert)
   Edge ecur = e0;
   do {
     Triangle *tri = ecur.tri();
-    if (tri->is_ghost()) {
-      continue;
+    if (!tri->is_ghost()) {
+      Edge eprev = ecur.triangle_pred();
+      float3 din = math::normalize(vert->co - v_src(eprev)->co);
+      float3 dout = math::normalize(v_dst(ecur)->co - vert->co);
+      float fac = saacos(-math::dot(din, dout));
+      ans = ans + fac * tri->normal();
     }
-    Edge eprev = ecur.triangle_pred();
-    float3 din = math::normalize(vert->co - v_src(eprev)->co);
-    float3 dout = math::normalize(v_dst(ecur)->co - vert->co);
-    float fac = saacos(-math::dot(din, dout));
-    ans = ans + fac * tri->normal();
     ecur = rot_ccw(ecur);
   } while (ecur != e0);
   ans = math::normalize(ans);
@@ -1104,17 +1099,6 @@ static Vector<Vector<Edge>> init_contour_inset(TriangleMesh &trimesh, Span<Vecto
   return ans;
 }
 
-static Array<Triangle *> triangle_set_to_sorted_array(const Set<Triangle *> tri_set)
-{
-  Array<Triangle *> ans(tri_set.size());
-  int i = 0;
-  for (Triangle *tri : tri_set) {
-    ans[i++] = tri;
-  }
-  std::sort(ans.begin(), ans.end(), triangle_id_less);
-  return ans;
-}
-
 static float det(const float3 &v1, const float3 &v2, const float3 &n)
 {
   return math::dot(math::cross_high_precision(v1, v2), n);
@@ -3016,8 +3000,10 @@ static Vector<Vector<Edge>> find_cycle_partition(const Vector<Edge> &edges)
   return ans;
 }
 
-/** Find and append the faces inside the wavefront cycle \a contour and append them to \a out_faces.  */
-static void append_interior_faces_for_cycle(Vector<Vector<int>> &out_faces, const Vector<Edge> contour)
+/** Find and append the faces inside the wavefront cycle \a contour and append them to \a
+ * out_faces.  */
+static void append_interior_faces_for_cycle(Vector<Vector<int>> &out_faces,
+                                            const Vector<Edge> contour)
 {
   constexpr int dbg_level = 0;
   if (dbg_level > 0) {
diff --git a/source/blender/blenlib/tests/BLI_mesh_inset_test.cc b/source/blender/blenlib/tests/BLI_mesh_inset_test.cc
index cf133bceea8..51f8132b21d 100644
--- a/source/blender/blenlib/tests/BLI_mesh_inset_test.cc
+++ b/source/blender/blenlib/tests/BLI_mesh_inset_test.cc
@@ -84,6 +84,7 @@ class InputHolder {
     input.face = spec_arrays_.face.as_span();
     input.contour = spec_arrays_.contour.as_span();
     input.inset_amount = amount;
+    input.slope = 0.0f;
     input.need_ids = false;
   }
 };



More information about the Bf-blender-cvs mailing list