28 Box(T _x, T _y, T _z, T _width, T _height, T _depth) {
29 reset(_x, _y, _z, _width, _height, _depth);
33 reset(_position.
x, _position.
y, _position.
z, _size.
x, _size.
y, _size.
z);
40 void reset(T _x, T _y, T _z, T _width, T _height, T _depth) {
51 void move(T _x, T _y, T _z) {
x += _x;
y += _y;
z += _z; }
55 T r1MinX = std::min(
x, static_cast<T>(
x +
width));
56 T r1MaxX = std::max(
x, static_cast<T>(
x +
width));
57 T r1MinY = std::min(
y, static_cast<T>(
y +
height));
58 T r1MaxY = std::max(
y, static_cast<T>(
y +
height));
59 T r1MinZ = std::min(
z, static_cast<T>(
z +
depth));
60 T r1MaxZ = std::max(
z, static_cast<T>(
z +
depth));
62 T r2MinX = std::min(box.
x, static_cast<T>(box.
x + box.
width));
63 T r2MaxX = std::max(box.
x, static_cast<T>(box.
x + box.
width));
64 T r2MinY = std::min(box.
y, static_cast<T>(box.
y + box.
height));
65 T r2MaxY = std::max(box.
y, static_cast<T>(box.
y + box.
height));
66 T r2MinZ = std::min(box.
z, static_cast<T>(box.
z + box.
depth));
67 T r2MaxZ = std::max(box.
z, static_cast<T>(box.
z + box.
depth));
69 T interLeft = std::max(r1MinX, r2MinX);
70 T interRight = std::min(r1MaxX, r2MaxX);
71 T interBottom = std::max(r1MinY, r2MinY);
72 T interTop = std::min(r1MaxY, r2MaxY);
73 T interFront = std::max(r1MinZ, r2MinZ);
74 T interBack = std::min(r1MaxZ, r2MaxZ);
76 return interLeft < interRight && interBottom < interTop && interFront < interBack;
103 #endif // GK_BOX_HPP_
void setPosition(Vector3< T > vector3)
Box operator-(const Vector3< T > &vector3) const
void reset(T _x, T _y, T _z, T _width, T _height, T _depth)
Box operator+(const Vector3< T > &vector3) const
Box(T _x, T _y, T _z, T _width, T _height, T _depth)
bool intersects(const Box< T > &box) const
Box & operator+=(const Vector3< T > &vector3)
Box & operator-=(const Vector3< T > &vector3)
void move(Vector3< T > d)
void move(T _x, T _y, T _z)
Vector3< T > position() const
Box(const Vector3< T > &_position, const Vector3< T > &_size)