diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-19 14:39:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-19 14:39:37 +0400 |
commit | 33e0bc6b486de3b597deaf35c07cb560c7dfefb1 (patch) | |
tree | 6073a96f8b013b332de915ad4f0d20ffaeec29f6 /source/blender/blenlib/intern | |
parent | 79b919644be280b57133344d4e6c84f4d9b479b4 (diff) |
code cleanup: avoid sqrt in isect_seg_seg_v2_point
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 5 |
1 files 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); |