Cleanup: remove compare_len_squared utility

There isn't any advantage to this over comparing the squared length.
This commit is contained in:
Campbell Barton 2019-03-19 00:35:24 +11:00
parent 606f3c74d3
commit 29039e5c74
4 changed files with 12 additions and 19 deletions

View File

@ -204,6 +204,7 @@ MINLINE float len_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESU
MINLINE float len_v2v2_int(const int v1[2], const int v2[2]);
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
MINLINE float len_squared_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
MINLINE float len_manhattan_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE int len_manhattan_v2v2_int(const int a[2], const int b[2]) ATTR_WARN_UNUSED_RESULT;
MINLINE float len_manhattan_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
@ -288,8 +289,6 @@ MINLINE bool compare_v3v3_relative(const float a[3], const float b[3], const flo
MINLINE bool compare_v4v4_relative(const float a[4], const float b[4], const float limit, const int max_ulps) ATTR_WARN_UNUSED_RESULT;
MINLINE bool compare_len_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
MINLINE bool compare_len_squared_v3v3(const float a[3], const float b[3], const float limit) ATTR_WARN_UNUSED_RESULT;
MINLINE bool compare_len_squared_v4v4(const float a[4], const float b[4], const float limit) ATTR_WARN_UNUSED_RESULT;
MINLINE float line_point_side_v2(const float l1[2], const float l2[2], const float pt[2]) ATTR_WARN_UNUSED_RESULT;

View File

@ -782,7 +782,7 @@ static void deduplicate_recursive(const struct DeDuplicateParams *p, uint i)
}
else {
if ((p->search != node->index) && (p->duplicates[node->index] == -1)) {
if (compare_len_squared_v3v3(node->co, p->search_co, p->range_sq)) {
if (len_squared_v3v3(node->co, p->search_co) <= p->range_sq) {
p->duplicates[node->index] = (int)p->search;
*p->duplicates_found += 1;
}

View File

@ -952,6 +952,14 @@ MINLINE float len_squared_v3v3(const float a[3], const float b[3])
return dot_v3v3(d, d);
}
MINLINE float len_squared_v4v4(const float a[4], const float b[4])
{
float d[4];
sub_v4_v4v4(d, b, a);
return dot_v4v4(d, d);
}
MINLINE float len_manhattan_v2v2(const float a[2], const float b[2])
{
float d[2];
@ -1197,20 +1205,6 @@ MINLINE bool compare_len_v3v3(const float v1[3], const float v2[3], const float
return (dot_v3v3(d, d) <= (limit * limit));
}
MINLINE bool compare_len_squared_v3v3(const float v1[3], const float v2[3], const float limit_sq)
{
float d[3];
sub_v3_v3v3(d, v1, v2);
return (dot_v3v3(d, d) <= limit_sq);
}
MINLINE bool compare_len_squared_v4v4(const float v1[4], const float v2[4], const float limit_sq)
{
float d[4];
sub_v4_v4v4(d, v1, v2);
return (dot_v4v4(d, d) <= limit_sq);
}
/**
* <pre>
* + l1

View File

@ -1415,7 +1415,7 @@ static void paint_2d_fill_add_pixel_byte(
rgba_uchar_to_float(color_f, color_b);
straight_to_premul_v4(color_f);
if (compare_len_squared_v4v4(color_f, color, threshold_sq)) {
if (len_squared_v4v4(color_f, color) <= threshold_sq) {
BLI_stack_push(stack, &coordinate);
}
BLI_BITMAP_SET(touched, coordinate, true);
@ -1434,7 +1434,7 @@ static void paint_2d_fill_add_pixel_float(
coordinate = ((size_t)y_px) * ibuf->x + x_px;
if (!BLI_BITMAP_TEST(touched, coordinate)) {
if (compare_len_squared_v4v4(ibuf->rect_float + 4 * coordinate, color, threshold_sq)) {
if (len_squared_v4v4(ibuf->rect_float + 4 * coordinate, color) <= threshold_sq) {
BLI_stack_push(stack, &coordinate);
}
BLI_BITMAP_SET(touched, coordinate, true);