- if (aabb.min.x - e < 0.0f || -aabb.max.x - e > 0.0f) {
- return false;
- }
- }
- }
-
- { // Y
- const glm::vec3 yaxis(M[1].x, M[1].y, M[1].z);
- const float e = glm::dot(yaxis, delta);
- const float f = glm::dot(ray.dir, yaxis);
-
- if (std::abs(f) > std::numeric_limits<float>::epsilon()) {
- t1.y = (e + aabb.min.y) / f;
- t2.y = (e + aabb.max.y) / f;
-
- t_min = std::max(t_min, std::min(t1.y, t2.y));
- t_max = std::min(t_max, std::max(t1.y, t2.y));
-
- if (t_max < t_min) {
- return false;
- }
- } else {
- if (aabb.min.y - e < 0.0f || -aabb.max.y - e > 0.0f) {
- return false;
- }
- }
- }
-
- { // Z
- const glm::vec3 zaxis(M[2].x, M[2].y, M[2].z);
- const float e = glm::dot(zaxis, delta);
- const float f = glm::dot(ray.dir, zaxis);
-
- if (std::abs(f) > std::numeric_limits<float>::epsilon()) {
- t1.z = (e + aabb.min.z) / f;
- t2.z = (e + aabb.max.z) / f;
-
- t_min = std::max(t_min, std::min(t1.z, t2.z));
- t_max = std::min(t_max, std::max(t1.z, t2.z));
-
- if (t_max < t_min) {
- return false;
- }
- } else {
- if (aabb.min.z - e < 0.0f || -aabb.max.z - e > 0.0f) {