alecjacobson / computer-graphics-bounding-volume-hierarchy

Computer Graphics Assignment about Bounding Volume Hierarchies
123 stars 45 forks source link

Clarification for "careful: if the ray or min_t lands inside the box this could still hit something stored inside the box, so this counts as a hit " #5

Closed velociraptor111 closed 6 years ago

velociraptor111 commented 6 years ago

What does this warning mean ? " careful: if the ray or min_t lands inside the box this could still hit something stored inside the box, so this counts as a hit ".

Also, from my understanding of the variable t, it should hold the parametric distance of the ray to the first hit of the box on the edges. So what does the sentence "min_t lands inside the box" really mean?

alecjacobson commented 6 years ago

Could you give this issue (and all future issues) a better title?

alecjacobson commented 6 years ago

Consider the case where the ray originates from inside the box and the box contains a triangle that the ray hits.

velociraptor111 commented 6 years ago

Woops forgot to create a title for the issue sorry .. Changed the title of this issue ..

Ahh I see .. In the case where the ray is originating from inside the box, does that mean we would only have one t value (since you only hit one edge of the box) as opposed to the regular two (tmin and tmax) values?

Also, does the variable t we are returning hold the parametric distance of the ray to the first hit of the box on the edges ?

Edited: In context with your example, I thought for the function ray_intersect_box we would only check if a Ray passes through a Bounding Box object, how would we know if there is a triangle within that specific bounding box?

zhtdavis commented 6 years ago

I think for ray_intersect_box you only need to check whether the ray hits the box or not, you don't to find the exact t value. You need to find the exact t value when you are doing intersection test for an actual object(not box). Only actual object will be the leaf for the tree. Since we are doing a post order traversal on the tree, the resulting t value will populate upward.

That's my current understanding on the material before the class. Correct me if I'm wrong.