diff --git a/CHANGELOG.md b/CHANGELOG.md index caa4dc1f..27cfb1f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/common/aabb.h b/src/common/aabb.h index ee830264..f4c629f1 100644 --- a/src/common/aabb.h +++ b/src/common/aabb.h @@ -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; }