Skip to content

Commit b26739f

Browse files
committed
workaround for incorrect ray intersections with open cones
1 parent 0ae57ef commit b26739f

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

CSG/csg_intersect_leaf_newcone.h

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,13 @@ void intersect_leaf_newcone( bool& valid_isect, float4& isect, const quad& q0, c
100100
const float4 roots = make_float4( t_near, t_far, t_cap1, t_cap2 );
101101
const float t_cand = fminf(roots) ;
102102

103-
valid_isect = t_cand > t_min && t_cand < RT_DEFAULT_MAX ;
104-
if(valid_isect)
105-
{
106-
if( t_cand == t_cap1 || t_cand == t_cap2 )
107-
{
108-
isect.x = 0.f ;
109-
isect.y = 0.f ;
110-
isect.z = t_cand == t_cap2 ? 1.f : -1.f ;
111-
}
112-
else
113-
{
114-
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 )) ;
115-
isect.x = n.x ;
116-
isect.y = n.y ;
117-
isect.z = n.z ;
118-
}
119-
isect.w = t_cand ;
120-
}
103+
float3 intersection_point = make_float3(o.x + t_cand * d.x, o.y + t_cand * d.y, o.z + t_cand * d.z);
104+
float3 n = normalize(make_float3(intersection_point.x, intersection_point.y, (z0 - intersection_point.z)*tth2));
105+
106+
isect.x = n.x;
107+
isect.y = n.y;
108+
isect.z = n.z;
109+
isect.w = t_cand;
121110
}
122111

123112

0 commit comments

Comments
 (0)