1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#pragma once
#include <array>
#include "Vector.hpp"
struct AABB {
AABB() = default;
AABB(Vector<3> min, Vector<3> max) : min(min), max(max) {}
explicit AABB(Vector<3> max) : max(max) {}
std::array<Vector<3>, 8> corners() const {
return {{
{min.x(), min.y(), min.z()},
{min.x(), min.y(), max.z()},
{min.x(), max.y(), min.z()},
{min.x(), max.y(), max.z()},
{max.x(), min.y(), min.z()},
{max.x(), min.y(), max.z()},
{max.x(), max.y(), min.z()},
{max.x(), max.y(), max.z()},
}};
}
AABB offset(Vector<3> by) const { return {min + by, max + by}; }
Vector<3> min, max;
};
|