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>2013-07-19 14:39:37 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-07-19 14:39:37 +0400
commit33e0bc6b486de3b597deaf35c07cb560c7dfefb1 (patch)
tree6073a96f8b013b332de915ad4f0d20ffaeec29f6
parent79b919644be280b57133344d4e6c84f4d9b479b4 (diff)
code cleanup: avoid sqrt in isect_seg_seg_v2_point
-rw-r--r--source/blender/blenlib/intern/math_geom.c5
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);