diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-07-14 05:55:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-07-14 05:55:38 +0400 |
commit | d9f39257f40d58caa53efcad112df9775f95d8bf (patch) | |
tree | 034569c38838000ad18290aa211a25946b66bc08 /source | |
parent | d56e6bf1bf82c2112913442e1a416fb6ebcc9fa5 (diff) |
Math Lib: add compare_len_squared_v3v3 from paint branch
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 11 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_removedoubles.c | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 4a18987e2e4..135050f4a3f 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -934,6 +934,17 @@ MINLINE bool compare_len_v3v3(const float v1[3], const float v2[3], const float return ((x * x + y * y + z * z) <= (limit * limit)); } +MINLINE bool compare_len_squared_v3v3(const float v1[3], const float v2[3], const float limit_sq) +{ + float x, y, z; + + x = v1[0] - v2[0]; + y = v1[1] - v2[1]; + z = v1[2] - v2[2]; + + return ((x * x + y * y + z * z) <= limit_sq); +} + MINLINE bool compare_v4v4(const float v1[4], const float v2[4], const float limit) { if (fabsf(v1[0] - v2[0]) <= limit) diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 814649c7dbf..954f31fc4a8 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -528,6 +528,7 @@ static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, int i, j, keepvert = 0; const float dist = BMO_slot_float_get(op->slots_in, "dist"); + const float dist_sq = dist * dist; const float dist3 = dist * 3.0f; /* Test whether keep_verts arg exists and is non-empty */ @@ -576,7 +577,7 @@ static void bmesh_find_doubles_common(BMesh *bm, BMOperator *op, continue; } - if (compare_len_v3v3(v_check->co, v_other->co, dist)) { + if (compare_len_squared_v3v3(v_check->co, v_other->co, dist_sq)) { /* If one vert is marked as keep, make sure it will be the target */ if (BMO_elem_flag_test(bm, v_other, VERT_KEEP)) { |