.\" Automatically generated by Pandoc 2.9.2.1 .\" .TH "rtcIntersect1" "3" "" "" "Embree Ray Tracing Kernels 4" .hy .SS NAME .IP .nf \f[C] rtcIntersect1 - finds the closest hit for a single ray \f[R] .fi .SS SYNOPSIS .IP .nf \f[C] #include void rtcIntersect1( RTCScene scene, struct RTCRayHit* rayhit struct RTCIntersectArguments* args = NULL ); \f[R] .fi .SS DESCRIPTION .PP The \f[C]rtcIntersect1\f[R] function finds the closest hit of a single ray (\f[C]rayhit\f[R] argument) with the scene (\f[C]scene\f[R] argument). The provided ray/hit structure contains the ray to intersect and some hit output fields that are filled when a hit is found. The passed optional arguments struct (\f[C]args\f[R] argument) can get used for advanced use cases, see section [rtcInitIntersectArguments] for more details. .PP To trace a ray, the user has to initialize the ray origin (\f[C]org\f[R] ray member), ray direction (\f[C]dir\f[R] ray member), ray segment (\f[C]tnear\f[R], \f[C]tfar\f[R] ray members), ray mask (\f[C]mask\f[R] ray member), and set the ray flags to \f[C]0\f[R] (\f[C]flags\f[R] ray member). The ray time (\f[C]time\f[R] ray member) must be initialized to a value in the range $[0, 1]. The ray segment has to be in the range [0,\[u2006]\[if]], thus ranges that start behind the ray origin are not valid, but ranges can reach to infinity. See Section [RTCRay] for the ray layout description. .PP The geometry ID (\f[C]geomID\f[R] hit member) of the hit data must be initialized to \f[C]RTC_INVALID_GEOMETRY_ID\f[R] (-1). .PP When no intersection is found, the ray/hit data is not updated. When an intersection is found, the hit distance is written into the \f[C]tfar\f[R] member of the ray and all hit data is set, such as unnormalized geometry normal in object space (\f[C]Ng\f[R] hit member), local hit coordinates (\f[C]u\f[R], \f[C]v\f[R] hit member), instance ID stack (\f[C]instID\f[R] hit member), geometry ID (\f[C]geomID\f[R] hit member), and primitive ID (\f[C]primID\f[R] hit member). See Section [RTCHit] for the hit layout description. .PP If the instance ID stack has a prefix of values not equal to \f[C]RTC_INVALID_GEOMETRY_ID\f[R], the instance ID on each level corresponds to the geometry ID of the hit instance of the higher-level scene, the geometry ID corresponds to the hit geometry inside the hit instanced scene, and the primitive ID corresponds to the n-th primitive of that geometry. .PP If level 0 of the instance ID stack is equal to \f[C]RTC_INVALID_GEOMETRY_ID\f[R], the geometry ID corresponds to the hit geometry inside the top-level scene, and the primitive ID corresponds to the n-th primitive of that geometry. .PP The implementation makes no guarantees that primitives whose hit distance is exactly at (or very close to) \f[C]tnear\f[R] or \f[C]tfar\f[R] are hit or missed. If you want to exclude intersections at \f[C]tnear\f[R] just pass a slightly enlarged \f[C]tnear\f[R], and if you want to include intersections at \f[C]tfar\f[R] pass a slightly enlarged \f[C]tfar\f[R]. .IP .nf \f[C] \f[R] .fi .PP The ray/hit structure must be aligned to 16 bytes. .SS EXIT STATUS .PP For performance reasons this function does not do any error checks, thus will not set any error flags on failure. .SS SEE ALSO .PP [rtcOccluded1], [rtcIntersect4/8/16], [RTCRayHit], [rtcInitIntersectArguments]