diff options
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 3 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_kdtree.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 22 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_2d.c | 4 |
4 files changed, 12 insertions, 19 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index f3908cf7462..c9285466259 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -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; diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index e9b8d173eb1..29e6446528a 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -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; } diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 80bdeec5949..f22b2a7a457 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -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 diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 990017d3a20..cad75efbf56 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -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); |