Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-10-02 08:09:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-10-02 14:07:39 +0300
commitdeb16defd5e10ded5c4000eeaf142ee91408e452 (patch)
tree33d9be295ab20726add21351b22889c6e42d1ccd /source/blender/blenlib/BLI_math_geom.h
parentff0938870ff800e160ac6dbe8d2b70980f01b5c5 (diff)
Math Lib: distance to AABB
Original code by @mano-wii, modified for general use.
Diffstat (limited to 'source/blender/blenlib/BLI_math_geom.h')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 0fef849c8fa..d0b59244384 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -119,6 +119,26 @@ float dist_squared_ray_to_seg_v3(
const float ray_origin[3], const float ray_direction[3],
const float v0[3], const float v1[3],
float r_point[3], float *r_depth);
+
+struct DistRayAABB_Precalc {
+ float ray_origin[3];
+ float ray_direction[3];
+ float ray_inv_dir[3];
+ bool sign[3];
+};
+void dist_squared_ray_to_aabb_precalc(
+ struct DistRayAABB_Precalc *neasrest_precalc,
+ const float ray_origin[3], const float ray_direction[3]);
+float dist_squared_ray_to_aabb(
+ const struct DistRayAABB_Precalc *data,
+ const float bb_min[3], const float bb_max[3],
+ float r_point[3], float *r_depth);
+/* when there is no advantage to precalc. */
+float dist_squared_to_ray_to_aabb_simple(
+ const float ray_origin[3], const float ray_direction[3],
+ const float bb_min[3], const float bb_max[3],
+ float r_point[3], float *r_depth);
+
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2]);
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3]);
void closest_to_line_segment_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2]);