diff options
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 18 |
2 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 640f3143009..ccdb94c3317 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -373,6 +373,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 ********************************/ void interp_weights_tri_v3(float w[3], const float a[3], const float b[3], const float c[3], const float p[3]); void interp_weights_quad_v3(float w[4], const float a[3], const float b[3], const float c[3], const float d[3], const float p[3]); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 12246473523..fb2a1e47895 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2979,19 +2979,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) { |