diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-02-11 10:19:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-02-11 10:21:02 +0300 |
commit | c5d0a2320498d1feb7cc2c68fc6504bb187d5a8d (patch) | |
tree | 7567cdfd01b476ba024fe8f0e02ef85934479acc /source/blender | |
parent | e08c2128af86ea027bd1e4163753cd9130e4af3c (diff) |
Fix T73348: Surface Deform distortion on bind with small faces
Thanks to @CodyWinch for finding the root cause
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index a17fecca303..1b428d7f054 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -4152,13 +4152,15 @@ struct Float2_Len { static float mean_value_half_tan_v3(const struct Float3_Len *d_curr, const struct Float3_Len *d_next) { - float cross[3], area; + float cross[3]; cross_v3_v3v3(cross, d_curr->dir, d_next->dir); - area = len_v3(cross); - if (LIKELY(fabsf(area) > FLT_EPSILON)) { + const float area = len_v3(cross); + /* Compare against zero since 'FLT_EPSILON' can be too large, see: T73348. */ + if (LIKELY(area != 0.0f)) { const float dot = dot_v3v3(d_curr->dir, d_next->dir); const float len = d_curr->len * d_next->len; - return (len - dot) / area; + const float result = (len - dot) / area; + return isfinite(result) ? result : 0.0f; } else { return 0.0f; @@ -4168,13 +4170,14 @@ static float mean_value_half_tan_v3(const struct Float3_Len *d_curr, static float mean_value_half_tan_v2(const struct Float2_Len *d_curr, const struct Float2_Len *d_next) { - float area; /* different from the 3d version but still correct */ - area = cross_v2v2(d_curr->dir, d_next->dir); - if (LIKELY(fabsf(area) > FLT_EPSILON)) { + const float area = cross_v2v2(d_curr->dir, d_next->dir); + /* Compare against zero since 'FLT_EPSILON' can be too large, see: T73348. */ + if (LIKELY(area != 0.0f)) { const float dot = dot_v2v2(d_curr->dir, d_next->dir); const float len = d_curr->len * d_next->len; - return (len - dot) / area; + const float result = (len - dot) / area; + return isfinite(result) ? result : 0.0f; } else { return 0.0f; |