[Bf-blender-cvs] [c5d0a232049] master: Fix T73348: Surface Deform distortion on bind with small faces
Campbell Barton
noreply at git.blender.org
Tue Feb 11 08:21:30 CET 2020
Commit: c5d0a2320498d1feb7cc2c68fc6504bb187d5a8d
Author: Campbell Barton
Date: Tue Feb 11 18:19:34 2020 +1100
Branches: master
https://developer.blender.org/rBc5d0a2320498d1feb7cc2c68fc6504bb187d5a8d
Fix T73348: Surface Deform distortion on bind with small faces
Thanks to @CodyWinch for finding the root cause
===================================================================
M source/blender/blenlib/intern/math_geom.c
===================================================================
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;
More information about the Bf-blender-cvs
mailing list