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

@ -4,12 +4,28 @@
#include "first_hit.h" #include "first_hit.h"
bool TriangleSoup::intersect( bool TriangleSoup::intersect(
const Ray & ray, const double min_t, double & t, Eigen::Vector3d & n) const const Ray & ray, const double min_t, double & t, Eigen::Vector3d & n) const
{ {
//////////////////////////////////////////////////////////////////////////// bool hit = false;
// Replace with your code here: /* Initialize to a value that will never be used. */
return false; 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;
} }