diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-12-21 20:51:13 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-12-21 20:54:45 +0300 |
commit | 8e331c34312e2a9945da84d9601fce8aba53f2ee (patch) | |
tree | 3a7c8bb25d8004903defdb11ae323bf4bf37781b /intern/cycles/kernel/geom/geom_curve_intersect.h | |
parent | c93fd8438c86f7df1b938a37b6034764caff0638 (diff) |
Fix T59565: NaN/crash with zero radius tip of hair curves.
Diffstat (limited to 'intern/cycles/kernel/geom/geom_curve_intersect.h')
-rw-r--r-- | intern/cycles/kernel/geom/geom_curve_intersect.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/intern/cycles/kernel/geom/geom_curve_intersect.h b/intern/cycles/kernel/geom/geom_curve_intersect.h index b6b58b52a29..5cf8713e3a8 100644 --- a/intern/cycles/kernel/geom/geom_curve_intersect.h +++ b/intern/cycles/kernel/geom/geom_curve_intersect.h @@ -874,13 +874,15 @@ ccl_device_inline float3 curve_refine(KernelGlobals *kg, float gd = isect->v; /* direction from inside to surface of curve */ - sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd); + float denom = fmaxf(P_curve[0].w + sd->u * l * gd, 1e-8f); + sd->Ng = (dif - tg * sd->u * l) / denom; /* adjustment for changing radius */ if(gd != 0.0f) { sd->Ng = sd->Ng - gd * tg; - sd->Ng = normalize(sd->Ng); } + + sd->Ng = normalize(sd->Ng); } sd->N = sd->Ng; |