//----------------------------------------------------------------------------
// William Baxter III's Ray Tracer
//
//     Project for Comp 238, Raster Graphics
//     University of North Carolina at Chapel Hill
//     
// $Id:$
//----------------------------------------------------------------------------

#include "wb3Plane.hpp"

const wb3Artifact* wb3Plane::Intersect(const Ray3f& r, float* dist, 
                                       const wb3Artifact *ignore) const
{
  float ndotv = m_N * r.V();
  const float eps = 1e-4f;
  if (this!=ignore && (ndotv < -eps || ndotv > eps))
  {
    *dist = - (m_fD + m_N * r.P())/ndotv;
    return this;
  }
  else return 0; // ray parallel or nearly-parallel to plane
}

