dilevin / computer-graphics-bounding-volume-hierarchy

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

What does the "descendent" do in AABBTree_ray_intersect #39

Open cuilantao opened 4 years ago

honglin-c commented 4 years ago

If the hit was found at a descendant, pass along a pointer to that descendant (only necessary for hierarchical Objects) (see object.h). Note that "AABBTree_ray_intersect" can be called recursively, and the "descendant" is set to the pointer to the leaf node being hit (if there is a hit).

amirhmk commented 4 years ago

@chl9797 Can you elaborate please? I'm not sure if I get what you mean

amirhmk commented 4 years ago

Just a little confusing when to use descendent->ray_intersection vs left-> and what to pass as the last argument. As I can see from the header files, once we are at the leafs that last argument doesn't even matter, is this correct? Not really sure descendent comes into play tbh

kyokeunpark commented 4 years ago

If you're currently evaluating a leaf node (non-AABBTree object), and you determine that this object is being hit before any other object, we need to set a reference to this object, so that when we go up in the chain of recursive call, the caller will still have a reference to the object that has been hit. Otherwise, how would the caller know which specific object the ray has hit?