feat: Intersect with TriangleSoup

This commit is contained in:
Tibo De Peuter 2024-10-05 21:22:07 +02:00
parent 38e185a3ef
commit 607590983c
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2

View file

@ -6,10 +6,26 @@
bool TriangleSoup::intersect(
const Ray & ray, const double min_t, double & t, Eigen::Vector3d & n) const
{
////////////////////////////////////////////////////////////////////////////
// Replace with your code here:
return false;
////////////////////////////////////////////////////////////////////////////
bool hit = false;
/* Initialize to a value that will never be used. */
t = -1;
/* Alternatively, use a max integer value, and remove the check t == -1. */
/* Store intermediate results that are not necessarily the first hit. */
double t_temp;
Eigen::Vector3d n_temp;
for (const auto & triangle : triangles) {
if (triangle->intersect(ray, min_t, t_temp, n_temp)) {
hit = true;
if (t == -1 || t_temp < t) {
t = t_temp;
n = n_temp;
}
}
}
return hit;
}