Skip to content

aabb ctor treats 2 params as extrema in any order #812

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

Merged
merged 2 commits into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Change Log -- Ray Tracing in One Weekend
- Change: Cleaned up multiple cases where the `inline` keyword was unnecessary, and reorganized
some global utility functions as either private static, or in better locations.
- Fix: Remove redundant `virtual` keyword for methods with `override` (#805)
- Change: `aabb` class constructor treats two params as extreme points in any orientation (#733)

### In One Weekend
- Added: More commentary about the choice between `double` and `float` (#752)
Expand Down
7 changes: 6 additions & 1 deletion src/common/aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
class aabb {
public:
aabb() {}
aabb(const point3& a, const point3& b) { minimum = a; maximum = b; }
aabb(const point3& a, const point3& b) {
// Treat the two points a and b as extrema for the bounding box, so we don't require a
// particular minimum/maximum coordinate order.
minimum = point3(fmin(a[0],b[0]), fmin(a[1],b[1]), fmin(a[2],b[2]));
maximum = point3(fmax(a[0],b[0]), fmax(a[1],b[1]), fmax(a[2],b[2]));
}

point3 min() const {return minimum; }
point3 max() const {return maximum; }
Expand Down