Fix #29594: cycles NaN values with window coordinates mapping.

This commit is contained in:
Brecht Van Lommel 2011-12-13 00:00:26 +00:00
parent 9e01abf777
commit 57a39c3a0c

@ -41,8 +41,9 @@ __device_inline float3 transform(const Transform *t, const float3 a)
{
float4 b = make_float4(a.x, a.y, a.z, 1.0f);
float3 c = make_float3(dot(t->x, b), dot(t->y, b), dot(t->z, b));
float w = dot(t->w, b);
return c/dot(t->w, b);
return (w != 0.0f)? c/w: make_float3(0.0f, 0.0f, 0.0f);
}
__device_inline float3 transform_direction(const Transform *t, const float3 a)