diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-04 09:48:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-09-04 15:06:36 +0300 |
commit | 2ea96df15990b46f11fa8b2f6065d53814cbc990 (patch) | |
tree | 9f0dbf80a9f9aad56fc67398d9148429ea811d10 /source/blender/blenlib/intern/math_geom.c | |
parent | f79c748246b075fddf719d2a7a7cbd764f4c5a60 (diff) |
Correct own error in line_point_factor
Passing zero epsilon allowed divide by zero.
Diffstat (limited to 'source/blender/blenlib/intern/math_geom.c')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index feb9f7d43ca..baee17e95db 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2175,6 +2175,9 @@ float closest_to_line_v2(float cp[2], const float p[2], const float l1[2], const /** * A simplified version of #closest_to_line_v3 * we only need to return the ``lambda`` + * + * \param epsilon: avoid approaching divide-by-zero. + * Passing a zero will just check for nonzero division. */ float line_point_factor_v3_ex( const float p[3], const float l1[3], const float l2[3], @@ -2189,7 +2192,7 @@ float line_point_factor_v3_ex( #else /* better check for zero */ dot = dot_v3v3(u, u); - return (fabsf(dot) >= epsilon) ? (dot_v3v3(u, h) / dot) : fallback; + return (fabsf(dot) > epsilon) ? (dot_v3v3(u, h) / dot) : fallback; #endif } float line_point_factor_v3( @@ -2211,7 +2214,7 @@ float line_point_factor_v2_ex( #else /* better check for zero */ dot = dot_v2v2(u, u); - return (fabsf(dot) >= epsilon) ? (dot_v2v2(u, h) / dot) : fallback; + return (fabsf(dot) > epsilon) ? (dot_v2v2(u, h) / dot) : fallback; #endif } |