Implement BVH
This commit is contained in:
11
interval.h
11
interval.h
@@ -12,6 +12,12 @@ class interval {
|
||||
|
||||
interval(double min, double max) : min(min), max(max) {}
|
||||
|
||||
interval(const interval& a, const interval& b) {
|
||||
// Create the interval tightly enclosing the two input intervals.
|
||||
min = a.min <= b.min ? a.min : b.min;
|
||||
max = a.max >= b.max ? a.max : b.max;
|
||||
}
|
||||
|
||||
double size() const {
|
||||
return max - min;
|
||||
}
|
||||
@@ -30,6 +36,11 @@ class interval {
|
||||
return x;
|
||||
}
|
||||
|
||||
interval expand(double delta) const {
|
||||
auto padding = delta / 2;
|
||||
return interval(min - padding, max + padding);
|
||||
}
|
||||
|
||||
static const interval empty, universe;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user