From 33e0bc6b486de3b597deaf35c07cb560c7dfefb1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Jul 2013 10:39:37 +0000 Subject: code cleanup: avoid sqrt in isect_seg_seg_v2_point --- source/blender/blenlib/intern/math_geom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 28bb97689d8..0e7ff521ce8 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -494,6 +494,7 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[ float a1, a2, b1, b2, c1, c2, d; float u, v; const float eps = 0.000001f; + const float eps_sq = eps * eps; a1 = v2[0] - v1[0]; b1 = v4[0] - v3[0]; @@ -510,8 +511,8 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[ float a[2], b[2], c[2]; float u2; - if (len_v2v2(v1, v2) == 0.0f) { - if (len_v2v2(v3, v4) > eps) { + if (equals_v2v2(v1, v2)) { + if (len_squared_v2v2(v3, v4) > eps_sq) { /* use non-point segment as basis */ SWAP(const float *, v1, v3); SWAP(const float *, v2, v4); -- cgit v1.2.3