minor AABB change
parent
f997674b48
commit
f4638907bd
|
@ -177,13 +177,28 @@ template <typename T> struct TAABB {
|
|||
value_type value = 0;
|
||||
if (p[i] < min[i])
|
||||
value = min[i] - p[i];
|
||||
if (p[i] > max[i])
|
||||
else if (p[i] > max[i])
|
||||
value = p[i] - max[i];
|
||||
result += value*value;
|
||||
}
|
||||
return std::sqrt(result);
|
||||
}
|
||||
|
||||
/// Calculate the minimum AABB-AABB distance
|
||||
inline value_type distanceTo(const TAABB &aabb) const {
|
||||
value_type result = 0;
|
||||
|
||||
for (int i=0; i<point_type::dim; ++i) {
|
||||
value_type value = 0;
|
||||
if (aabb.max[i] < min[i])
|
||||
value = min[i] - aabb.max[i];
|
||||
else if (aabb.min[i] > max[i])
|
||||
value = aabb.min[i] - max[i];
|
||||
result += value*value;
|
||||
}
|
||||
return std::sqrt(result);
|
||||
}
|
||||
|
||||
/// Return whether this bounding box is valid
|
||||
inline bool isValid() const {
|
||||
for (int i=0; i<point_type::dim; ++i)
|
||||
|
|
Loading…
Reference in New Issue