#include "IntersectableWrapper.h" #include "Mesh.h" #include "Triangle3.h" namespace GtpVisibilityPreprocessor { AxisAlignedBox3 TriangleIntersectable::GetBox() const { return mItem.GetBoundingBox(); } int TriangleIntersectable::CastRay(Ray &ray) { float nearestT = MAX_FLOAT; float t; Vector3 nearestNormal; if (ray.GetType() == Ray::LOCAL_RAY && !ray.intersections.empty()) nearestT = ray.intersections[0].mT; const int hitCode = mItem.CastRay(ray, t, nearestT, nearestNormal); nearestT = t; if ((hitCode == Ray::INTERSECTION) && (ray.GetType() == Ray::LOCAL_RAY)) { if (!ray.intersections.empty()) { ray.intersections[0] = Ray::Intersection(nearestT, nearestNormal, this, 0); } else { ray.intersections.push_back(Ray::Intersection(nearestT, nearestNormal, this, 0)); } return 1; } return 0; } int TriangleIntersectable::NumberOfFaces() const { return 1; } Vector3 TriangleIntersectable::GetNormal(const int idx) const { return mItem.GetNormal(); } }