From bf4d8ffe3ab8a85a8e3071d54a1eaf84960ddae3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 5 Mar 2010 15:36:05 +0000 Subject: [PATCH] Fix #21458: tangent space normal maps didn't work correct in some cases due to recent fix to avoid division by zero. --- source/blender/blenlib/intern/math_geom.c | 8 +++++--- 1 file 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);