[Bf-blender-cvs] [d9f3925] master: Math Lib: add compare_len_squared_v3v3 from paint branch

Campbell Barton noreply at git.blender.org
Mon Jul 14 03:59:26 CEST 2014


Commit: d9f39257f40d58caa53efcad112df9775f95d8bf
Author: Campbell Barton
Date:   Mon Jul 14 11:55:38 2014 +1000
https://developer.blender.org/rBd9f39257f40d58caa53efcad112df9775f95d8bf

Math Lib: add compare_len_squared_v3v3 from paint branch

===================================================================

M	source/blender/blenlib/intern/math_vector_inline.c
M	source/blender/bmesh/operators/bmo_removedoubles.c

===================================================================

diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index 4a18987..135050f 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 814649c..954f31f 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)) {




More information about the Bf-blender-cvs mailing list