implement box intersect

This commit is contained in:
Dynamitos
2025-01-24 19:23:58 +01:00
parent 854399c775
commit 2111238935
2 changed files with 13 additions and 4 deletions
+12 -3
View File
@@ -43,10 +43,19 @@ struct AABB
max = glm::vec3(std::max(max.x, transformed.x), std::max(max.y, transformed.y), std::max(max.z, transformed.z));
}
}
bool intersects(Ray ray)
bool intersects(Ray ray, float tmin, float tmax)
{
assert(false && "TODO");
return false;
glm::vec3 invD = 1.0f / ray.direction;
glm::vec3 t0s = glm::vec3(min - ray.origin) * invD;
glm::vec3 t1s = glm::vec3(max - ray.origin) * invD;
glm::vec3 tsmaller = std::min(t0s, t1s);
glm::vec3 tbigger = std::max(t0s, t1s);
tmin = std::max(tmin, std::max(tsmaller.x, std::max(tsmaller.y, tsmaller.z)));
tmax = std::min(tmax, std::min(tbigger.x, std::min(tbigger.y, tbigger.z)));
return (tmin < tmax);
}
static AABB combine(AABB lhs, AABB rhs)
{