File indexing completed on 2026-04-09 07:48:54
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 LEAF_FUNC
0025 void intersect_leaf_infcylinder( bool& valid_isect, float4& isect, const quad& q0, const quad& q1, const float t_min, const float3& ray_origin, const float3& ray_direction )
0026 {
0027 const float r = q0.f.w ;
0028
0029 const float3& O = ray_origin ;
0030 const float3& D = ray_direction ;
0031
0032 float a = D.x*D.x + D.y*D.y ;
0033 float b = O.x*D.x + O.y*D.y ;
0034 float c = O.x*O.x + O.y*O.y - r*r ;
0035
0036 float disc = b*b-a*c;
0037
0038 if(disc > 0.0f)
0039 {
0040 float t_NEAR, t_FAR, sdisc ;
0041
0042 robust_quadratic_roots(t_NEAR, t_FAR, disc, sdisc, a, b, c);
0043
0044 float t_cand = sdisc > 0.f ? ( t_NEAR > t_min ? t_NEAR : t_FAR ) : t_min ;
0045
0046 valid_isect = t_cand > t_min ;
0047
0048 if( valid_isect )
0049 {
0050 isect.x = (O.x + t_cand*D.x)/r ;
0051 isect.y = (O.y + t_cand*D.y)/r ;
0052 isect.z = 0.f ;
0053 isect.w = t_cand ;
0054 }
0055 }
0056 }
0057