Open grandrx10 opened 1 month ago
The base case would be if the ray has intersected with a box.
Then it checks if there is left descendant, it checks if the ray intersects with left descendant (tree). The same goes for right tree.
So, if the left descendent is a leaf, then the descendant
should be set to the leaf object pointer. Otherwise the descendant
is just the left tree pointer. The same goes for right tree.
Can I assume that leaf objects will automatically return themselves as a descendant when I call ray intersect on them?
Yes I believe so. The ray_intersect
should be overloaded when called on a leaf object.
So the tricky part is how do you know if the returned descendant object is a leaf or not.
Within AABBTree_ray_intersection, I recursively set descendant but I never implement a base case for it. I'm wondering where I can actually implement this base case, or if I even need to (does an object have a base implemented descendant return?)
The reason why I am asking about this is because when running the code, I encountered a seg fault (see below) which I traced to a function that uses the descendant return.
Can I get some clarification on how the descendant is supposed to be used? (I have read the other post about descendant, and I am still unclear on how to do so.)