Add [[nodiscard]] to AABB functions
This commit is contained in:
parent
475fd8fe90
commit
a0353edd89
1 changed files with 5 additions and 5 deletions
|
@ -3,25 +3,25 @@
|
||||||
struct AABB {
|
struct AABB {
|
||||||
glm::vec3 min, max;
|
glm::vec3 min, max;
|
||||||
|
|
||||||
glm::vec3 center() const {
|
[[nodiscard]] glm::vec3 center() const {
|
||||||
return 0.5f * (max + min);
|
return 0.5f * (max + min);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 extent() const {
|
[[nodiscard]] glm::vec3 extent() const {
|
||||||
return max - center();
|
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));
|
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 (
|
return (
|
||||||
max.x > extent.min.x && min.x < extent.max.x && max.y > extent.min.y && min.y < extent.max.y &&
|
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);
|
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 t1 = (min.x - ray.origin.x) / ray.direction.x;
|
||||||
const float t2 = (max.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;
|
const float t3 = (min.y - ray.origin.y) / ray.direction.y;
|
||||||
|
|
Loading…
Add table
Reference in a new issue