dilevin / computer-graphics-bounding-volume-hierarchy

Computer Graphics Assignment about Bounding Volume Hierarchies
6 stars 5 forks source link

Why do we need the max_t parameter? #42

Open RaihanFaruque opened 4 years ago

honglin-c commented 4 years ago

max_t helps you keep track of where the ray first intersects with an object and avoid unnecessary search. Consider the scenario when there are multiple objects (or triangles of a mesh) along the path of a ray. Suppose you find the intersection of the ray and a triangle and get a t_value, you can set max_t to the t_value you just get for future query within the AABBTree. So you can avoid unnecessary queries if the min of the t_value of another bounding box you calculated (possibly of a non-leaf node) is larger than max_t, which means that the box is farther than your previous hit.