Math Lib: add compare_len_squared_v3v3 from paint branch
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user