Skip to content

Commit 5bb3bd1

Browse files
authored
Fix numeric error
1 parent 1843440 commit 5bb3bd1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

RadeonRays/src/kernels/CL/common.cl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,16 @@ float fast_intersect_triangle(ray r, float3 v1, float3 v2, float3 v3, float t_ma
174174
float3 const e2 = v3 - v1;
175175
float3 const s1 = cross(r.d.xyz, e2);
176176

177+
float denom = dot(s1, e1);
178+
if (denom == 0.f)
179+
{
180+
return t_max;
181+
}
182+
177183
#ifdef USE_SAFE_MATH
178-
float const invd = 1.f / dot(s1, e1);
184+
float const invd = 1.f / denom;
179185
#else
180-
float const invd = native_recip(dot(s1, e1));
186+
float const invd = native_recip(denom);
181187
#endif
182188

183189
float3 const d = r.o.xyz - v1;

0 commit comments

Comments
 (0)