Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/engine/utility/include/aabb.hpp
2020-08-11 12:07:21 -04:00

23 lines
720 B
C++
Executable file

#pragma once
#include <array>
#include "vector.hpp"
/// A 3D axis aligned bounding box.
struct AABB {
Vector3 min, max;
};
/// Creates an array of 8 points, each of these being one extreme of the bounding box..
inline std::array<Vector3, 8> get_points(const AABB& aabb) {
return {
Vector3(aabb.min.x, aabb.min.y, aabb.min.z),
Vector3(aabb.max.x, aabb.min.y, aabb.min.z),
Vector3(aabb.min.x, aabb.max.y, aabb.min.z),
Vector3(aabb.max.x, aabb.max.y, aabb.min.z),
Vector3(aabb.min.x, aabb.min.y, aabb.max.z),
Vector3(aabb.max.x, aabb.min.y, aabb.max.z),
Vector3(aabb.min.x, aabb.max.y, aabb.max.z),
Vector3(aabb.max.x, aabb.max.y, aabb.max.z)};
}