Closed cgyurgyik closed 4 years ago
There is a really important point to make here. The statement "We know if discr <= 0 there is no hit." is not completely correct. Consider the first test case in our test suite: the value of the discriminant that we want to consider is positive; the ray does intersect the circle, just not in the time frame that we consider. In particular, the Graphics Gems algorithm is a base algorithm that we've developed our initialization phase on; the GG algorithm doesn't make any mention of time.
I'm not sure if the remaining comments are relevant after that point.
Ok I posted this a while back so I'll have to look into this again
Just sharing some thoughts as I look through the code for this next progress report. This isn't something we need to worry about now, but it is an optimization we can consider in the future. We know if
discr <= 0
there is no hit. If it is not, then we have an intersection.We can then calculate the first discriminant for
r_a
, and do an early exit if eithert < t1 < t_end
ort < t2 < t_end
. This allows for early exit ifr_a
time fulfills our requirement. In the current code, we always calculate for bothr_a
andr_b
This pseudocode would look something like this:
In summary, this would allow us to totally skip the calculation of the
discr
and other necessary equations fortime_array_b
.