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/math/include/aabb.hpp
2021-05-12 09:56:44 -04:00

25 lines
No EOL
825 B
C++

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