diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-05 18:36:05 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-05 18:36:05 +0300 |
commit | bf4d8ffe3ab8a85a8e3071d54a1eaf84960ddae3 (patch) | |
tree | 7125b8c83afd2dbc7efa7fe8b1e95e6048a4805d /source/blender | |
parent | 422241c4e61f252260d91ad35da65019e910a43e (diff) |
Fix #21458: tangent space normal maps didn't work correct in some
cases due to recent fix to avoid division by zero.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 7e12cec5023..d12aa1051dc 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1852,10 +1852,12 @@ void tangent_from_uv(float *uv1, float *uv2, float *uv3, float *co1, float *co2, float s2= uv3[0] - uv1[0]; float t1= uv2[1] - uv1[1]; float t2= uv3[1] - uv1[1]; + float det= (s1 * t2 - s2 * t1); - if(s1 && s2 && t1 && t2) { /* otherwise 'tang' becomes nan */ - float tangv[3], ct[3], e1[3], e2[3], det; - det= 1.0f / (s1 * t2 - s2 * t1); + if(det != 0.0f) { /* otherwise 'tang' becomes nan */ + float tangv[3], ct[3], e1[3], e2[3]; + + det= 1.0f/det; /* normals in render are inversed... */ sub_v3_v3v3(e1, co1, co2); |