feat: Intersect with TriangleSoup
This commit is contained in:
parent
38e185a3ef
commit
607590983c
1 changed files with 21 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Reference in a new issue