15 #include <vsg/maths/vec3.h>
28 vec_type min =
vec_type(std::numeric_limits<value_type>::max(), std::numeric_limits<value_type>::max(), std::numeric_limits<value_type>::max());
29 vec_type max =
vec_type(std::numeric_limits<value_type>::lowest(), std::numeric_limits<value_type>::lowest(), std::numeric_limits<value_type>::lowest());
31 constexpr
t_box() =
default;
43 constexpr
t_box& operator=(
const t_box&) =
default;
45 constexpr std::size_t size()
const {
return 6; }
47 value_type& operator[](std::size_t i) {
return data()[i]; }
48 value_type operator[](std::size_t i)
const {
return data()[i]; }
50 bool valid()
const {
return min.x <= max.x; }
52 explicit operator bool()
const noexcept {
return valid(); }
54 T* data() {
return min.data(); }
55 const T* data()
const {
return min.data(); }
59 min =
vec_type(std::numeric_limits<value_type>::max(), std::numeric_limits<value_type>::max(), std::numeric_limits<value_type>::max());
60 max =
vec_type(std::numeric_limits<value_type>::lowest(), std::numeric_limits<value_type>::lowest(), std::numeric_limits<value_type>::lowest());
69 void add(value_type x, value_type y, value_type z)
71 if (x < min.x) min.x = x;
72 if (y < min.y) min.y = y;
73 if (z < min.z) min.z = z;
74 if (x > max.x) max.x = x;
75 if (y > max.y) max.y = y;
76 if (z > max.z) max.z = z;
82 if (bb.min.x < min.x) min.x = bb.min.x;
83 if (bb.min.y < min.y) min.y = bb.min.y;
84 if (bb.min.z < min.z) min.z = bb.min.z;
85 if (bb.max.x > max.x) max.x = bb.max.x;
86 if (bb.max.y > max.y) max.y = bb.max.y;
87 if (bb.max.z > max.z) max.z = bb.max.z;
100 return (lhs.min == rhs.min) && (lhs.max == rhs.max);
104 constexpr
bool operator!=(
const t_box<T>& lhs,
const t_box<T>& rhs)
106 return (lhs.min != rhs.min) || (lhs.max != rhs.max);
110 constexpr
bool operator<(
const t_box<T>& lhs,
const t_box<T>& rhs)
112 if (lhs.min < rhs.min)
return true;
113 if (rhs.min < lhs.min)
return false;
114 return lhs.max < rhs.max;
t_box template class that represents an axis aligned bounding box
Definition: box.h:24
t_vec3 template class that represents a 3D vector
Definition: vec3.h:34