src/Node.cpp

Go to the documentation of this file.
00001 
00002 #include "Node.h"
00003 #include "Primitive.h"
00004 
00005 
00014 bool Node::leafIntersect(Ray & ray, float min, float max) const
00015 {
00016     // here we store a copy of the ray
00017     Ray r = ray;
00018     bool found = false;
00019 
00020 //    LOG(min << " " << max);
00021     // search for the nearest intersection
00022     for (unsigned int i=0; i < mPrimitives.size(); i++)
00023     {
00024         // if there is an intersection
00025         if (mPrimitives[i]->intersect(r))
00026         {
00027 //        LOG(r << " .. " << r.hit() << " .. " << r.t());
00028             // do only proceed if the intersection is near than previous
00029             if (min - EPSILON <= r.t() && r.t() <= max + EPSILON)
00030             {
00031 //        LOG(ray << " .. " << ray.hit() << " .. " << ray.t());
00032                 ray = r;
00033                 ray.setHit(mPrimitives[i], r.t());
00034 
00035                 max = r.t();
00036                 found = true;
00037             }
00038         }
00039     }
00040 //    if (!found) LOG("FALSE");
00041 
00042     return found;
00043 }
00044 
00045 

Generated on Fri Feb 1 00:01:42 2008 for Grayfall by  doxygen 1.5.1