From 1ec9ad773bba0b941e927430ddc49d00d15e0fb2 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Wed, 30 Jul 2025 10:26:22 -0400 Subject: [PATCH] workaround for incorrect ray intersections with open cones --- CSG/csg_intersect_leaf_newcone.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/CSG/csg_intersect_leaf_newcone.h b/CSG/csg_intersect_leaf_newcone.h index 576c39bff..371c713fd 100644 --- a/CSG/csg_intersect_leaf_newcone.h +++ b/CSG/csg_intersect_leaf_newcone.h @@ -100,23 +100,16 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c const float4 roots = make_float4( t_near, t_far, t_cap1, t_cap2 ); const float t_cand = fminf(roots) ; - valid_isect = t_cand > t_min && t_cand < RT_DEFAULT_MAX ; - if(valid_isect) + valid_isect = (t_cand > t_min && t_cand < RT_DEFAULT_MAX); + if (valid_isect) { - if( t_cand == t_cap1 || t_cand == t_cap2 ) - { - isect.x = 0.f ; - isect.y = 0.f ; - isect.z = t_cand == t_cap2 ? 1.f : -1.f ; - } - else - { - float3 n = normalize(make_float3( o.x+t_cand*d.x, o.y+t_cand*d.y, (z0-(o.z+t_cand*d.z))*tth2 )) ; - isect.x = n.x ; - isect.y = n.y ; - isect.z = n.z ; - } - isect.w = t_cand ; + float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z); + float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z)*tth2)); + + isect.x = n.x; + isect.y = n.y; + isect.z = n.z; + isect.w = t_cand; } }