From 6202bc82b858d8f6876c6c20ec62dd0a16209087 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 6 Feb 2019 11:47:46 +0100 Subject: Fix T60935: More numerically stable distance to ray computation The old function was numerically very unstable for 2 reasons: computing the square and then subtracting the results. In the example in T60935 all precision was lost and it returned the distance 0 for all points. I also removed the `depth` parameter since it wasn't used and computing it would have made the code more complicated. Reviewers: brecht, campbellbarton Differential Revision: https://developer.blender.org/D4308 --- source/blender/blenlib/BLI_math_geom.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (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 a564e5481b9..54a4a38b15e 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -109,9 +109,9 @@ float dist_signed_squared_to_corner_v3v3v3( const float p[3], const float v1[3], const float v2[3], const float v3[3], const float axis_ref[3]); -float dist_squared_to_ray_v3( +float dist_squared_to_ray_v3_normalized( const float ray_origin[3], const float ray_direction[3], - const float co[3], float *r_depth); + const float co[3]); 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], -- cgit v1.2.3