[Bf-blender-cvs] [d8585e184ae] master: New boolean: fixed a bug in coplanar intersect.

Howard Trickey noreply at git.blender.org
Sat Aug 29 17:33:49 CEST 2020


Commit: d8585e184aef90f80d1721c2c89eaf303c67e309
Author: Howard Trickey
Date:   Sat Aug 29 11:31:47 2020 -0400
Branches: master
https://developer.blender.org/rBd8585e184aef90f80d1721c2c89eaf303c67e309

New boolean: fixed a bug in coplanar intersect.

The code that found coplanar clusters was not updating a bounding box.
Also, code that was detecting non-trivial coplanar intersects was
slightly wrong, but that would not have caused any functional problems.

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

M	source/blender/blenlib/intern/mesh_intersect.cc

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

diff --git a/source/blender/blenlib/intern/mesh_intersect.cc b/source/blender/blenlib/intern/mesh_intersect.cc
index 80b37ea6f44..8c412617b13 100644
--- a/source/blender/blenlib/intern/mesh_intersect.cc
+++ b/source/blender/blenlib/intern/mesh_intersect.cc
@@ -927,7 +927,7 @@ class CoplanarCluster {
   void add_tri(int t, const BoundingBox &bb)
   {
     tris_.append(t);
-    bb_ = bb;
+    bb_.combine(bb);
   }
   int tot_tri() const
   {
@@ -1129,6 +1129,8 @@ static bool non_trivially_2d_point_in_tri(const int orients[3][3], int pi)
  * overlap in a "hex" pattern? That is, the overlap region is a hexagon, which
  * one gets by having, each point of one triangle being strictly right-of one
  * edge of the other and strictly left of the other two edges; and vice versa.
+ * In addition, it must not be the case that all of the points of one triangle
+ * are totally to one side of one edge of the other triangle, and vice versa.
  */
 static bool non_trivially_2d_hex_overlap(int orients[2][3][3])
 {
@@ -1139,6 +1141,10 @@ static bool non_trivially_2d_hex_overlap(int orients[2][3][3])
       if (!ok) {
         return false;
       }
+      int s = orients[ab][0][i] + orients[ab][1][i] + orients[ab][2][i];
+      if (s == 3 || s == -3) {
+        return false;
+      }
     }
   }
   return true;
@@ -2845,6 +2851,9 @@ static CoplanarClusterInfo find_clusters(const IMesh &tm, const Array<BoundingBo
       Vector<CoplanarCluster *> int_cls;
       Vector<CoplanarCluster *> no_int_cls;
       for (CoplanarCluster &cl : curcls) {
+        if (dbg_level > 1) {
+          std::cout << "consider intersecting with cluster " << cl << "\n";
+        }
         if (bbs_might_intersect(tri_bb[t], cl.bounding_box()) &&
             non_trivially_coplanar_intersects(tm, t, cl, proj_axis)) {
           if (dbg_level > 1) {
@@ -3026,6 +3035,7 @@ IMesh trimesh_nary_intersect(const IMesh &tm_in,
       for (int t : tm_in.face_index_range()) {
         std::cout << "shape(" << t << ") = " << shape_fn(tm_in.face(t)->orig) << "\n";
       }
+      write_obj_mesh(const_cast<IMesh &>(tm_in), "trimesh_input");
     }
   }
 #  ifdef PERFDEBUG



More information about the Bf-blender-cvs mailing list