[Bf-blender-cvs] [e747d9851a0] newboolean: Added double tri tri intersection, able to do coplanar.

Howard Trickey noreply at git.blender.org
Fri Aug 30 17:08:52 CEST 2019


Commit: e747d9851a0f217db3a9f54a190c6e9049ecf151
Author: Howard Trickey
Date:   Fri Aug 30 11:07:33 2019 -0400
Branches: newboolean
https://developer.blender.org/rBe747d9851a0f217db3a9f54a190c6e9049ecf151

Added double tri tri intersection, able to do coplanar.

Added needed double routines to BLI but left new routine
in bmesh_boolean.c for now, while developing it more.

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

M	source/blender/blenlib/BLI_math_base.h
M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_geom.c
M	source/blender/blenlib/intern/math_vector.c
M	source/blender/blenlib/intern/math_vector_inline.c
M	source/blender/bmesh/tools/bmesh_boolean.c

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

diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h
index 7b770f2dd3e..2695fe1da2d 100644
--- a/source/blender/blenlib/BLI_math_base.h
+++ b/source/blender/blenlib/BLI_math_base.h
@@ -216,6 +216,14 @@ double double_round(double x, int ndigits);
     } \
     (void)0
 
+#  define BLI_ASSERT_UNIT_V3_DB(v) \
+    { \
+      const double _test_unit = len_squared_v3_db(v); \
+      BLI_assert(!(fabs(_test_unit - 1.0) >= (double)BLI_ASSERT_UNIT_EPSILON) || \
+                 !(fabs(_test_unit) >= (double)BLI_ASSERT_UNIT_EPSILON)); \
+    } \
+    (void)0
+
 #  define BLI_ASSERT_UNIT_V2(v) \
     { \
       const float _test_unit = len_squared_v2(v); \
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index afcfb405ddb..6013407428b 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -42,6 +42,7 @@ extern "C" {
 /********************************** Polygons *********************************/
 
 float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]);
+double normal_tri_v3_db(double r[3], const double a[3], const double b[3], const double c[3]);
 float normal_quad_v3(
     float r[3], const float a[3], const float b[3], const float c[3], const float d[3]);
 float normal_poly_v3(float r[3], const float verts[][3], unsigned int nr);
@@ -204,6 +205,7 @@ void closest_to_line_segment_v3(float r_close[3],
 void closest_to_plane_normalized_v3(float r_close[3], const float plane[4], const float pt[3]);
 void closest_to_plane_v3(float r_close[3], const float plane[4], const float pt[3]);
 void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], const float pt[3]);
+void closest_to_plane3_normalized_v3_db(double r_close[3], const double plane[3], const double pt[3]);
 void closest_to_plane3_v3(float r_close[3], const float plane[3], const float pt[3]);
 
 /* Set 'r' to the point in triangle (t1, t2, t3) closest to point 'p' */
@@ -224,6 +226,11 @@ float line_point_factor_v3_ex(const float p[3],
                               const float l2[3],
                               const float epsilon,
                               const float fallback);
+double line_point_factor_v3_ex_db(const double p[3],
+                              const double l1[3],
+                              const double l2[3],
+                              const double epsilon,
+                              const double fallback);
 float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3]);
 
 float line_point_factor_v2_ex(const float p[2],
@@ -342,6 +349,10 @@ bool isect_plane_plane_v3(const float plane_a[4],
                           const float plane_b[4],
                           float r_isect_co[3],
                           float r_isect_no[3]) ATTR_WARN_UNUSED_RESULT;
+bool isect_plane_plane_v3_db(const double plane_a[4],
+                          const double plane_b[4],
+                          double r_isect_co[3],
+                          double r_isect_no[3]) ATTR_WARN_UNUSED_RESULT;
 
 /* line/ray triangle */
 bool isect_line_segment_tri_v3(const float p1[3],
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index e19d61db05e..aa3c7194d36 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -111,6 +111,7 @@ MINLINE void add_v2_v2v2_int(int r[2], const int a[2], const int b[2]);
 MINLINE void add_v3_v3(float r[3], const float a[3]);
 MINLINE void add_v3_v3_db(double r[3], const double a[3]);
 MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3]);
+MINLINE void add_v3_v3v3_db(double r[3], const double a[3], const double b[3]);
 MINLINE void add_v4_v4(float r[4], const float a[4]);
 MINLINE void add_v4_v4v4(float r[4], const float a[4], const float b[4]);
 
@@ -134,7 +135,9 @@ MINLINE void mul_v2_fl(float r[2], float f);
 MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f);
 MINLINE void mul_v3_fl(float r[3], float f);
 MINLINE void mul_v3db_db(double r[3], double f);
+MINLINE void mul_v3db_db(double r[3], double f);
 MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f);
+MINLINE void mul_v3db_v3dbdb(double r[3], const double a[3], double f);
 MINLINE void mul_v2_v2(float r[2], const float a[2]);
 MINLINE void mul_v2_v2v2(float r[2], const float a[2], const float b[2]);
 MINLINE void mul_v3_v3(float r[3], const float a[3]);
@@ -155,9 +158,11 @@ MINLINE float dot_m4_v3_row_z(const float M[4][4], const float a[3]) ATTR_WARN_U
 
 MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f);
 MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
+MINLINE void madd_v3db_v3dbdb(double r[3], const double a[3], double f);
 MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);
 MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f);
 MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f);
+MINLINE void madd_v3_v3v3db_db(double r[3], const double a[3], const double b[3], double f);
 MINLINE void madd_v3_v3v3v3(float r[3], const float a[3], const float b[3], const float c[3]);
 MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f);
 MINLINE void madd_v4_v4v4(float r[4], const float a[4], const float b[4]);
@@ -213,6 +218,7 @@ MINLINE void star_m3_v3(float rmat[3][3], float a[3]);
 MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE double len_squared_v2_db(const double v[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE double len_squared_v3_db(const double v[3]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float len_manhattan_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE int len_manhattan_v2_int(const int v[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float len_manhattan_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT;
@@ -228,7 +234,9 @@ MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]) ATTR_WARN_U
 MINLINE int len_manhattan_v2v2_int(const int a[2], const int b[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE double len_v3_db(const double a[3]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE double len_v3v3_db(const double a[3], const double b[3]) ATTR_WARN_UNUSED_RESULT;
 
 MINLINE float normalize_v2_length(float r[2], const float unit_scale);
 MINLINE float normalize_v2_v2_length(float r[2], const float a[2], const float unit_scale);
@@ -239,6 +247,7 @@ MINLINE double normalize_v3_length_d(double n[3], const double unit_scale);
 MINLINE float normalize_v2(float r[2]);
 MINLINE float normalize_v2_v2(float r[2], const float a[2]);
 MINLINE float normalize_v3(float r[3]);
+MINLINE float normalize_v3(float r[3]);
 MINLINE float normalize_v3_v3(float r[3], const float a[3]);
 MINLINE double normalize_v3_d(double n[3]);
 
@@ -357,6 +366,10 @@ MINLINE float line_point_side_v2(const float l1[2],
                                  const float l2[2],
                                  const float pt[2]) ATTR_WARN_UNUSED_RESULT;
 
+MINLINE double line_point_side_v2_db(const double l1[2],
+                                 const double l2[2],
+                                 const double pt[2]) ATTR_WARN_UNUSED_RESULT;
+
 /********************************** Angles ***********************************/
 /* - angle with 2 arguments is angle between vector                          */
 /* - angle with 3 arguments is angle between 3 points at the middle point    */
@@ -399,6 +412,7 @@ void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_pr
 void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3]);
 void project_plane_v2_v2v2(float out[2], const float p[2], const float v_plane[2]);
 void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3]);
+void project_plane_normalized_v3_v3v3_db(double out[3], const double p[3], const double v_plane[3]);
 void project_plane_normalized_v2_v2v2(float out[2], const float p[2], const float v_plane[2]);
 void project_v3_plane(float out[3], const float plane_no[3], const float plane_co[3]);
 void reflect_v3_v3v3(float out[3], const float vec[3], const float normal[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index e9ec706a338..2299de404f7 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -66,6 +66,23 @@ float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const floa
   return normalize_v3(n);
 }
 
+double normal_tri_v3_db(double n[3], const double v1[3], const double v2[3], const double v3[3])
+{
+  double n1[3], n2[3];
+
+  n1[0] = v1[0] - v2[0];
+  n2[0] = v2[0] - v3[0];
+  n1[1] = v1[1] - v2[1];
+  n2[1] = v2[1] - v3[1];
+  n1[2] = v1[2] - v2[2];
+  n2[2] = v2[2] - v3[2];
+  n[0] = n1[1] * n2[2] - n1[2] * n2[1];
+  n[1] = n1[2] * n2[0] - n1[0] * n2[2];
+  n[2] = n1[0] * n2[1] - n1[1] * n2[0];
+
+  return normalize_v3_d(n);
+}
+
 float normal_quad_v3(
     float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
 {
@@ -413,6 +430,13 @@ void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], con
   madd_v3_v3v3fl(r_close, pt, plane, -side);
 }
 
+void closest_to_plane3_normalized_v3_db(double r_close[3], const double plane[3], const double pt[3])
+{
+  const double side = dot_v3v3_db(plane, pt);
+  BLI_ASSERT_UNIT_V3_DB(plane);
+  madd_v3_v3v3db_db(r_close, pt, plane, -side);
+}
+
 float dist_signed_squared_to_plane_v3(const float pt[3], const float plane[4])
 {
   const float len_sq = len_squared_v3(plane);
@@ -2289,6 +2313,41 @@ bool isect_plane_plane_v3(const float plane_a[4],
   }
 }
 
+bool isect_plane_plane_v3_db(const double plane_a[4],
+                          const double plane_b[4],
+                          double r_isect_co[3],


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list