1
Fork 0

Add [[nodiscard]] to AABB functions

This commit is contained in:
Joshua Goins 2024-09-25 10:59:05 +02:00
parent 475fd8fe90
commit a0353edd89

View file

@ -3,25 +3,25 @@
struct AABB {
glm::vec3 min, max;
glm::vec3 center() const {
[[nodiscard]] glm::vec3 center() const {
return 0.5f * (max + min);
}
glm::vec3 extent() const {
[[nodiscard]] glm::vec3 extent() const {
return max - center();
}
bool contains(const glm::vec3 point) const {
[[nodiscard]] bool contains(const glm::vec3 point) const {
return glm::all(glm::lessThan(point, max)) && glm::all(glm::greaterThan(point, min));
}
bool inside(const AABB extent) const {
[[nodiscard]] bool inside(const AABB extent) const {
return (
max.x > extent.min.x && min.x < extent.max.x && max.y > extent.min.y && min.y < extent.max.y &&
max.z > extent.min.z && min.z < extent.max.z);
}
bool contains(const Ray& ray) const {
[[nodiscard]] bool contains(const Ray& ray) const {
const float t1 = (min.x - ray.origin.x) / ray.direction.x;
const float t2 = (max.x - ray.origin.x) / ray.direction.x;
const float t3 = (min.y - ray.origin.y) / ray.direction.y;