From 71919efd78149a305bea4db18d80f9434abeca33 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 21 Aug 2015 17:45:04 +1000 Subject: Math Lib: watertight intersection function From Cycles with some very minor differences. --- source/blender/blenlib/BLI_math_geom.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/blender/blenlib/BLI_math_geom.h') diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index ec1bb3cb8ca..1a25f9f897f 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -203,6 +203,27 @@ bool isect_tri_tri_epsilon_v3( float r_i1[3], float r_i2[3], const float epsilon); +/* water-tight raycast (requires pre-calculation) */ +struct IsectRayPrecalc { + /* Maximal dimension kz, and orthogonal dimensions. */ + int kx, ky, kz; + + /* Shear constants. */ + float sx, sy, sz; +}; + +void isect_ray_tri_watertight_v3_precalc( + struct IsectRayPrecalc *isect_precalc, const float dir[3]); +bool isect_ray_tri_watertight_v3( + const float P[3], const struct IsectRayPrecalc *isect_precalc, + const float v0[3], const float v1[3], const float v2[3], + float *r_dist, float r_uv[2]); +/* slower version which calculates IsectRayPrecalc each time */ +bool isect_ray_tri_watertight_v3_simple( + const float P[3], const float dir[3], + const float v0[3], const float v1[3], const float v2[3], + float *r_lambda, float r_uv[2]); + /* point in polygon */ bool isect_point_poly_v2(const float pt[2], const float verts[][2], const unsigned int nr, const bool use_holes); bool isect_point_poly_v2_int(const int pt[2], const int verts[][2], const unsigned int nr, const bool use_holes); -- cgit v1.2.3