Following from the "user_geometry" example. I am mixing analytical spheres and triangulated geometry.
The sphere intersection function has a signature of void sphereIntersectFunc(void* spheres_i, RTCRay& ray, size_t item);
My algorithm simply sets up the rays, loops over them and calls
In the "user defined intersection" function for the sphere(s). I notice in the passed RTCRay structure two things that I find a bit confusing.
- the tnear and tfar values are not 0.0 and inf as I would expect. They are often a "segment" of the ray. I can understand this may be an optimization based on a geometry space subdivision. It appears I should restrict any intersection to only be within the passed tnear and tfar.
- the RTCRay structure sometimes also contains a geomID == the triangulated geometry ID. That is, the ray seems to already have intersected some part of the triangulated geometry before being passed to the "sphere" intersection routine. I really don't understand this. I would expect that once a ray has intersected a geometry, it would return immediately from rtcIntersect.