If you use this code with a very wide angle cone it can fail when the camera gets near the apex.
The problem is with this line of code:
/* Point - cone test */
if ((diff - sphereRadius * sinAngle * coneNormal).Dot(coneNormal) > 0.0f)
{
I don't understand the exact math here but that statement is causing some valid intersections to get discarded.
I worked around this by adding my own checks for when the camera is above or below the cone, or within the radius of the apex.
If you use this code with a very wide angle cone it can fail when the camera gets near the apex.
The problem is with this line of code:
I don't understand the exact math here but that statement is causing some valid intersections to get discarded.
I worked around this by adding my own checks for when the camera is above or below the cone, or within the radius of the apex.