Exemplo n.º 1
0
bool Mesh
  ::intersect(const Ray &r, float &t, DifferentialGeometry &dg) const
{
  // create a TriangleIntersector
  TriangleIntersector intersector;
  intersector.init();
  intersector.mMesh = this;

  if(mTree.intersect(r.getAnchor(), r.getDirection(),
                     r.getInterval()[0], r.getInterval()[1],
                     intersector))
  {
    t = intersector.mT;
    const Triangle &tri = *intersector.mHitFace;

    // fill out DifferentialGeometry details
    getDifferentialGeometry(tri, r(t),
                            intersector.mBarycentricCoordinates[0],
                            intersector.mBarycentricCoordinates[1],
                            dg);
    return true;
  } // end if

  return false;
} // end Mesh::intersect()
Exemplo n.º 2
0
bool Mesh
  ::intersect(const Ray &r) const
{
  // create a TriangleShadower
  TriangleShadower shadower = {this};
  return mTree.shadow(r.getAnchor(), r.getDirection(), r.getInterval()[0], r.getInterval()[1], shadower);
} // end Mesh::intersect()