diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-22 22:23:54 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-22 22:33:07 +0400 |
commit | f2c483d108a33cb30f3f9c984c289e98a25ce5c2 (patch) | |
tree | 130f3e05dc45de7603a222c417a281c4efa0c65b /source/blender/blenlib | |
parent | a892cf683be27b15a87ae0d9c21b5ed512497a1a (diff) |
Fix T39429: Project paint error with UV bleed
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_geom.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom_inline.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 6000b8d5f23..f4bcc810846 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -319,6 +319,8 @@ MINLINE int poly_to_tri_count(const int poly_count, const int corner_count); MINLINE float shell_angle_to_dist(const float angle); MINLINE float shell_v3v3_normalized_to_dist(const float a[3], const float b[3]); MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2]); +MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3]); +MINLINE float shell_v2v2_mid_normalized_to_dist(const float a[2], const float b[2]); /**************************** Inline Definitions ******************************/ diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 1e54dd11a76..5a64ed63ecf 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -259,6 +259,34 @@ MINLINE float shell_v2v2_normalized_to_dist(const float a[2], const float b[2]) return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos); } +/** + * equivalent to ``shell_angle_to_dist(angle_normalized_v3v3(a, b) / 2)`` + */ +MINLINE float shell_v3v3_mid_normalized_to_dist(const float a[3], const float b[3]) +{ + float angle_cos; + float ab[3]; + BLI_ASSERT_UNIT_V3(a); + BLI_ASSERT_UNIT_V3(b); + add_v3_v3v3(ab, a, b); + angle_cos = (normalize_v3(ab) != 0.0f) ? fabsf(dot_v3v3(a, ab)) : 0.0f; + return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos); +} + +/** + * equivalent to ``shell_angle_to_dist(angle_normalized_v2v2(a, b) / 2)`` + */ +MINLINE float shell_v2v2_mid_normalized_to_dist(const float a[2], const float b[2]) +{ + float angle_cos; + float ab[2]; + BLI_ASSERT_UNIT_V2(a); + BLI_ASSERT_UNIT_V2(b); + add_v2_v2v2(ab, a, b); + angle_cos = (normalize_v2(ab) != 0.0f) ? fabsf(dot_v2v2(a, ab)) : 0.0f; + return (UNLIKELY(angle_cos < SMALL_NUMBER)) ? 1.0f : (1.0f / angle_cos); +} + #undef SMALL_NUMBER #endif /* __MATH_GEOM_INLINE_C__ */ |