Previous | Next --- Slide 20 of 50
Back to Lecture Thumbnails
marshmallow

In the provided code, why is the final if statement "hit2.t < closest.t"? Shouldn't it be the HitInfo corresponding to second? ie, if first was child2, shouldn't we check if "hit1.t < closest.t"?

Sybil

Wouldn't the code for "NVHNode* second" be "(hit1.t <= hit2.t) ? child2: child1;" instead? Else if "NVHNode* first" is child1, e.g. hit1.t < hit2.t, then "NVHNode* second" would also be child1

Osoii

Another reason we still need to do the second hitbox check is that the two hitboxes might overlap each other (just like the picture in the slide), so even the ray actually intersect a primitive in the first box, it still has a chance to hit a closer point in the second box (a primitive that lies in the second box intersect with the ray first). But I wonder if this scenario can be avoided by cleverly assign primitives into the boxes (building a better tree).

Sherwin

I also have the doubts as @marshmallow and @Sybil.

I believe the code should be:

HitInfo hit1 = intersect(ray, node->child1->bbox); HitInfo hit2 = intersect(ray, node->child2->bbox);

NVHNode* first = (hit1.t <= hit2.t) ? child1 : child2; NVHNode* sec <= hit2.t) ? child2 : child1; HitInfo* sec <= hit2.t) ? &hit2; : &hit1;

find_closest_hit(ray, first, closest); if (second_hit_info->t < closest.t) find_closest_hit(ray, second, closest);

pw123

Yeah, I had a similar question as @Osoii, is there a better way to assign primitives to avoid that situation?

dranzer

Yup have the same doubt in the code. We are assigning first and second the exact same way therefore not really doing anything useful and by the lecture content it seems like @Sherwin and @Sybil have the correct code.