-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change hittable::bounding_box
method signature
#859
Comments
- Now directly returns the aabb value. All hittables will return some bounding box, though in some cases the bounding box will be empty. - Removed interval and aabb operator+= methods, in exange for value-based operator+ functions. Resolves #859
@hollasch Could you not create a default constructor for AABB() that creates the object using the opposite extremes? I noticed something similar was done in aabb() : minimum(infinity*Point3(1,1,1)), maximum(-infinity*Point3(1,1,1)) {} The hit for an AABB checks the following: if (t_max <= t_min)
return false; When you are using the extremes it will return false. This would clean up the aabb bbox = aabb();
if (objects.empty())
return bbox; // unhittable
aabb temp_box;
for (const auto& object : objects)
{
object->bounding_box(temp_box);
output_box = surrounding_box(output_box, temp_box);
}
return bbox; |
I'm having difficulty understanding what exactly you're proposing. Are you reporting a bug in the new Taking your comments one-by-one, the new AABB() constructor effectively already does what you're suggesting, because The The current implementation of |
Current signature is
bool bounding_box(aabb& output_box) const
.Currently, the only way it can return
false
is from ahittable_list
object with no children.That means that ever caller much check the return value before processing the bounding box, an operation that's frequently unnecessary, and a speed bump.
There are two ways to approach this:
1. Use the new
Interval::empty
capabilityFor cases (or the current single case) where the bounding box is empty, return an empty
aabb
. This can be implemented with aaabb::is_empty()
method that returns true iff any of its dimension intervals are empty. Alternatively, we could just skip the check and work with the box normally. Generally, computing the hull of bounding boxes with an empty box should just computationally yield the correct result (like adding zero to a sum). One tricky challenge is the transform classes (liketranslate
androtate_y
). These may need to check the box first, but that's easily done, and only such cases need to inspect the return frombounding_box
.2. Empty bounding boxes just bound a single arbitrary point
For example, an empty
hittable_list
could just return the box around the origin. Everything would still work, it's just that in rare occasions you might find the box enlarged considerably when it contributes to other faraway bounding boxes. The code would still work, it just might be less optimized than it otherwise could be. Also note that we wouldn't normally encounter ahittable_list
with no children.Generally, I lean toward option 1. It's quite useful to have a AABB class that can handle empty and universe boxes, and in the end you still end up with code that's incrementally simpler than what we have today.
The text was updated successfully, but these errors were encountered: