[Bf-blender-cvs] [215df08c0f] cloth-improvements: Expose slice intersection function (math_geom)

Luca Rood noreply at git.blender.org
Sat Mar 4 06:22:35 CET 2017


Commit: 215df08c0f01e6e5e20a9c5eb05f08c03808ac7c
Author: Luca Rood
Date:   Fri Mar 3 20:36:50 2017 -0300
Branches: cloth-improvements
https://developer.blender.org/rB215df08c0f01e6e5e20a9c5eb05f08c03808ac7c

Expose slice intersection function (math_geom)

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

M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/intern/math_geom.c

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

diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 46e780c379..6decd9449d 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -326,6 +326,8 @@ bool clip_segment_v3_plane_n(
         const float p1[3], const float p2[3], const float plane_array[][4], const int plane_tot,
         float r_p1[3], float r_p2[3]);
 
+bool point_in_slice_seg(float p[3], float l1[3], float l2[3]);
+
 /****************************** Interpolation ********************************/
 
 /* tri or quad, d can be NULL */
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 2610fbde34..b142706412 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2730,19 +2730,27 @@ static bool point_in_slice(const float p[3], const float v1[3], const float l1[3
 	return (h >= 0.0f && h <= 1.0f);
 }
 
-#if 0
-
 /* adult sister defining the slice planes by the origin and the normal
  * NOTE |normal| may not be 1 but defining the thickness of the slice */
-static int point_in_slice_as(float p[3], float origin[3], float normal[3])
+static bool point_in_slice_as(float p[3], float origin[3], float normal[3])
 {
 	float h, rp[3];
 	sub_v3_v3v3(rp, p, origin);
 	h = dot_v3v3(normal, rp) / dot_v3v3(normal, normal);
-	if (h < 0.0f || h > 1.0f) return 0;
-	return 1;
+	if (h < 0.0f || h > 1.0f) return false;
+	return true;
 }
 
+bool point_in_slice_seg(float p[3], float l1[3], float l2[3])
+{
+	float normal[3];
+
+	sub_v3_v3v3(normal, l2, l1);
+
+	return point_in_slice_as(p, l1, normal);
+}
+
+#if 0
 /*mama (knowing the squared length of the normal) */
 static int point_in_slice_m(float p[3], float origin[3], float normal[3], float lns)
 {




More information about the Bf-blender-cvs mailing list